repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
fjoncourt/jfwknop | src/main/java/com/cipherdyne/jfwknop/ExternalCommand.java | // Path: src/main/java/com/cipherdyne/gui/IConsole.java
// public interface IConsole {
// /**
// * Append a message to a console
// *
// * @param msg Message to append to the console
// */
// public void appendToConsole(String msg);
// }
| import com.cipherdyne.gui.IConsole;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.jfwknop;
/**
* This class intends to provide an interface to run external commands periodically or only once.
*/
public class ExternalCommand implements Runnable {
// Logger
static final Logger LOGGER = LogManager.getLogger(ExternalCommand.class.getName());
// Command line to execute - can be more than one arguments - space separated list
private final String[] args;
// Timeout before two executions - Set to 0 to run the only command once
private final long period;
// Set to false when a periodic command has to be stoppped
private boolean isRunning;
// IConsole interface used to log external command output | // Path: src/main/java/com/cipherdyne/gui/IConsole.java
// public interface IConsole {
// /**
// * Append a message to a console
// *
// * @param msg Message to append to the console
// */
// public void appendToConsole(String msg);
// }
// Path: src/main/java/com/cipherdyne/jfwknop/ExternalCommand.java
import com.cipherdyne.gui.IConsole;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.jfwknop;
/**
* This class intends to provide an interface to run external commands periodically or only once.
*/
public class ExternalCommand implements Runnable {
// Logger
static final Logger LOGGER = LogManager.getLogger(ExternalCommand.class.getName());
// Command line to execute - can be more than one arguments - space separated list
private final String[] args;
// Timeout before two executions - Set to 0 to run the only command once
private final long period;
// Set to false when a periodic command has to be stoppped
private boolean isRunning;
// IConsole interface used to log external command output | private final IConsole console; |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/ssh/SshFileTableModel.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import com.cipherdyne.utils.InternationalizationHelper;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.table.AbstractTableModel; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ssh;
/**
*
*/
public class SshFileTableModel extends AbstractTableModel {
// Defaut transfer status
static public final String EXCHANGE_FILE_STATUS_INIT = "-----";
// filename is column 0 of the table model
static public final int FILENAME_COL_ID = 0;
// Exchange file status is column 1 of the table model
static public final int EXCHANGE_FILE_STATUS_COL_ID = 1;
// Name of the available columns in the table model
final private String[] columnNames = { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/gui/ssh/SshFileTableModel.java
import com.cipherdyne.utils.InternationalizationHelper;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.table.AbstractTableModel;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ssh;
/**
*
*/
public class SshFileTableModel extends AbstractTableModel {
// Defaut transfer status
static public final String EXCHANGE_FILE_STATUS_INIT = "-----";
// filename is column 0 of the table model
static public final int FILENAME_COL_ID = 0;
// Exchange file status is column 1 of the table model
static public final int EXCHANGE_FILE_STATUS_COL_ID = 1;
// Name of the available columns in the table model
final private String[] columnNames = { | InternationalizationHelper.getMessage("i18n.filename"), |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/about/About.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import com.cipherdyne.utils.InternationalizationHelper;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.about;
/**
* About window provides information about the application version, licence, copyright...
*
* @author Franck Joncourt
*/
public class About extends JDialog {
/**
* About dialog constructor
*
* @param parentFrame parent frame we inherit
*/
public About(JFrame parentFrame) { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/gui/about/About.java
import com.cipherdyne.utils.InternationalizationHelper;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.about;
/**
* About window provides information about the application version, licence, copyright...
*
* @author Franck Joncourt
*/
public class About extends JDialog {
/**
* About dialog constructor
*
* @param parentFrame parent frame we inherit
*/
public About(JFrame parentFrame) { | super(parentFrame, InternationalizationHelper.getMessage("i18n.about"), true); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/gpg/GpgTableModel.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
import com.cipherdyne.utils.InternationalizationHelper;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.Security;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.AbstractTableModel;
import org.bouncycastle.jce.provider.BouncyCastleProvider; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.gpg;
/**
*
*/
public class GpgTableModel extends AbstractTableModel {
// KEY ID is column 0 of the table model
static public final int KEY_ID_COL = 0;
// USER ID is column 1 of the table model
static public final int USER_ID_COL = 1;
// Name of the available columns in the table model
final private String[] columnNames = { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/gui/gpg/GpgTableModel.java
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
import com.cipherdyne.utils.InternationalizationHelper;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.Security;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.AbstractTableModel;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.gpg;
/**
*
*/
public class GpgTableModel extends AbstractTableModel {
// KEY ID is column 0 of the table model
static public final int KEY_ID_COL = 0;
// USER ID is column 1 of the table model
static public final int USER_ID_COL = 1;
// Name of the available columns in the table model
final private String[] columnNames = { | InternationalizationHelper.getMessage("i18n.key.id"), |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/ip/IpTableModel.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import com.cipherdyne.utils.InternationalizationHelper;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.swing.table.AbstractTableModel; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ip;
/**
* Table model used to list IPV4 or IPV6 addresses of the host
*/
public class IpTableModel extends AbstractTableModel {
// Network interface is column 0 of the table model
static public final int NETWORK_IFACE_COL_ID = 0;
// IP address is column 1 of the table model
static public final int IP_ADDRESS_COL_ID = 1;
// Name of the available columns in the table model
final private String[] columnNames = { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/gui/ip/IpTableModel.java
import com.cipherdyne.utils.InternationalizationHelper;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.swing.table.AbstractTableModel;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ip;
/**
* Table model used to list IPV4 or IPV6 addresses of the host
*/
public class IpTableModel extends AbstractTableModel {
// Network interface is column 0 of the table model
static public final int NETWORK_IFACE_COL_ID = 0;
// IP address is column 1 of the table model
static public final int IP_ADDRESS_COL_ID = 1;
// Name of the available columns in the table model
final private String[] columnNames = { | InternationalizationHelper.getMessage("i18n.network.interface.id"), |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/wizard/views/IWizardView.java | // Path: src/main/java/com/cipherdyne/gui/components/IFwknopVariable.java
// public interface IFwknopVariable {
// void setText(final String val);
//
// String getText();
//
// void setDefaultValue();
//
// boolean isDefault();
// }
//
// Path: src/main/java/com/cipherdyne/gui/wizard/EnumWizardButton.java
// public enum EnumWizardButton {
// CANCEL("i18n.wizard.cancel"),
// BACK("i18n.wizard.back"),
// NEXT("i18n.wizard.next"),
// FINISH("i18n.wizard.finish"),
// GENERATE_AES_KEY("i18n.wizard.generate.aes.key"),
// GENERATE_HMAC_KEY("i18n.wizard.generate.hmac.key"),
// BROWSE_FOR_GPG_HOMEDIR("i18n.wizard.browse.for.gpg.homedir"),
// CREATE_GPG_HOMEDIR("i18n.wizard.create.gpg.homedir"),
// BROWSE_FOR_GPG_SIGNER_ID("i18n.wizard.browse.for.gpg.signerid"),
// BROWSE_FOR_GPG_RECIPIENT_ID("i18n.wizard.browse.for.gpg.recipientid");
//
// final private String description;
//
// private EnumWizardButton(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return InternationalizationHelper.getMessage(this.description);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/wizard/EnumWizardVariable.java
// public enum EnumWizardVariable {
// ENCRYPTION_MODE("i18n.wizard.encryptionmode.description"),
// AES_KEY("i18n.wizard.key.description"),
// HMAC_KEY("i18n.wizard.hmac.description"),
// REMOTE_HOST("i18n.wizard.remotehost.description"),
// ACCESS("i18n.wizard.access.description"),
// GPG_HOME_DIRECTORY("i18n.wizard.gnupg.homedirectory.description"),
// GPG_SIGNER_ID("i18n.wizard.gnupg.signerid.description"),
// GPG_SIGNER_PASSWORD("i18n.wizard.gnupg.signerid.password"),
// GPG_RECIPIENT_ID("i18n.wizard.gnupg.recipientid.description");
//
// private final String description;
//
// private EnumWizardVariable(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return InternationalizationHelper.getMessage(this.description);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/wizard/EnumWizardView.java
// public enum EnumWizardView {
// SELECT_CRYPTO {
// @Override
// public IWizardView getView() {
// return new CryptoView();
// }
// },
// SETUP_AES {
// @Override
// public IWizardView getView() {
// return new AesView();
// }
// },
// SETUP_HMAC {
// @Override
// public IWizardView getView() {
// return new HmacView();
// }
// },
// SETUP_ACCESS {
// @Override
// public IWizardView getView() {
// return new AccessView();
// }
// },
// SETUP_GPG_HOME_DIRECTORY {
// @Override
// public IWizardView getView() {
// return new GpgHomeDirectoryView();
// }
// },
// SETUP_GPG_SIGNER_ID {
// @Override
// public IWizardView getView() {
// return new GpgSignerIdView();
// }
// },
// SETUP_GPG_RECIPIENT_ID {
// @Override
// public IWizardView getView() {
// return new GpgRecipientIdView();
// }
// },
// SETUP_REMOTE_HOST {
// @Override
// public IWizardView getView() {
// return new RemoteHostView();
// }
// };
//
// public abstract IWizardView getView();
// }
| import com.cipherdyne.gui.components.IFwknopVariable;
import com.cipherdyne.gui.wizard.EnumWizardButton;
import com.cipherdyne.gui.wizard.EnumWizardVariable;
import com.cipherdyne.gui.wizard.EnumWizardView;
import java.util.Map;
import javax.swing.JButton; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.wizard.views;
/**
*
* @author Franck Joncourt
*/
public interface IWizardView {
public void initialize(Map<EnumWizardVariable, IFwknopVariable> varMap, Map<EnumWizardButton, JButton> btnMap);
| // Path: src/main/java/com/cipherdyne/gui/components/IFwknopVariable.java
// public interface IFwknopVariable {
// void setText(final String val);
//
// String getText();
//
// void setDefaultValue();
//
// boolean isDefault();
// }
//
// Path: src/main/java/com/cipherdyne/gui/wizard/EnumWizardButton.java
// public enum EnumWizardButton {
// CANCEL("i18n.wizard.cancel"),
// BACK("i18n.wizard.back"),
// NEXT("i18n.wizard.next"),
// FINISH("i18n.wizard.finish"),
// GENERATE_AES_KEY("i18n.wizard.generate.aes.key"),
// GENERATE_HMAC_KEY("i18n.wizard.generate.hmac.key"),
// BROWSE_FOR_GPG_HOMEDIR("i18n.wizard.browse.for.gpg.homedir"),
// CREATE_GPG_HOMEDIR("i18n.wizard.create.gpg.homedir"),
// BROWSE_FOR_GPG_SIGNER_ID("i18n.wizard.browse.for.gpg.signerid"),
// BROWSE_FOR_GPG_RECIPIENT_ID("i18n.wizard.browse.for.gpg.recipientid");
//
// final private String description;
//
// private EnumWizardButton(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return InternationalizationHelper.getMessage(this.description);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/wizard/EnumWizardVariable.java
// public enum EnumWizardVariable {
// ENCRYPTION_MODE("i18n.wizard.encryptionmode.description"),
// AES_KEY("i18n.wizard.key.description"),
// HMAC_KEY("i18n.wizard.hmac.description"),
// REMOTE_HOST("i18n.wizard.remotehost.description"),
// ACCESS("i18n.wizard.access.description"),
// GPG_HOME_DIRECTORY("i18n.wizard.gnupg.homedirectory.description"),
// GPG_SIGNER_ID("i18n.wizard.gnupg.signerid.description"),
// GPG_SIGNER_PASSWORD("i18n.wizard.gnupg.signerid.password"),
// GPG_RECIPIENT_ID("i18n.wizard.gnupg.recipientid.description");
//
// private final String description;
//
// private EnumWizardVariable(String description) {
// this.description = description;
// }
//
// public String getDescription() {
// return InternationalizationHelper.getMessage(this.description);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/wizard/EnumWizardView.java
// public enum EnumWizardView {
// SELECT_CRYPTO {
// @Override
// public IWizardView getView() {
// return new CryptoView();
// }
// },
// SETUP_AES {
// @Override
// public IWizardView getView() {
// return new AesView();
// }
// },
// SETUP_HMAC {
// @Override
// public IWizardView getView() {
// return new HmacView();
// }
// },
// SETUP_ACCESS {
// @Override
// public IWizardView getView() {
// return new AccessView();
// }
// },
// SETUP_GPG_HOME_DIRECTORY {
// @Override
// public IWizardView getView() {
// return new GpgHomeDirectoryView();
// }
// },
// SETUP_GPG_SIGNER_ID {
// @Override
// public IWizardView getView() {
// return new GpgSignerIdView();
// }
// },
// SETUP_GPG_RECIPIENT_ID {
// @Override
// public IWizardView getView() {
// return new GpgRecipientIdView();
// }
// },
// SETUP_REMOTE_HOST {
// @Override
// public IWizardView getView() {
// return new RemoteHostView();
// }
// };
//
// public abstract IWizardView getView();
// }
// Path: src/main/java/com/cipherdyne/gui/wizard/views/IWizardView.java
import com.cipherdyne.gui.components.IFwknopVariable;
import com.cipherdyne.gui.wizard.EnumWizardButton;
import com.cipherdyne.gui.wizard.EnumWizardVariable;
import com.cipherdyne.gui.wizard.EnumWizardView;
import java.util.Map;
import javax.swing.JButton;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.wizard.views;
/**
*
* @author Franck Joncourt
*/
public interface IWizardView {
public void initialize(Map<EnumWizardVariable, IFwknopVariable> varMap, Map<EnumWizardButton, JButton> btnMap);
| public EnumWizardView getNextPanel(); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/gpg/GpgKeySettingsView.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopTextField.java
// public class JFwknopTextField extends JTextField implements IFwknopVariable {
//
// private static final long serialVersionUID = 1L;
// private final String defaultVal;
//
// public JFwknopTextField(final String val) {
// super(val);
// this.defaultVal = val;
// this.addFocusListener(new FocusListener() {
// @Override
// public void focusGained(FocusEvent e) {
// }
//
// @Override
// public void focusLost(FocusEvent e) {
// if (((JFwknopTextField) e.getSource()).getText().equals(StringUtils.EMPTY)) {
// setDefaultValue();
// }
// }
// });
// }
//
// @Override
// public void setDefaultValue() {
// this.setText(this.defaultVal);
// }
//
// @Override
// public boolean isDefault() {
// boolean def = false;
// if (this.defaultVal.equals(this.getText())) {
// def = true;
// }
//
// return def;
// }
// }
| import com.cipherdyne.utils.InternationalizationHelper;
import com.cipherdyne.gui.components.JFwknopTextField;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.gpg;
/**
*
* @author franck
*/
public class GpgKeySettingsView extends JDialog {
private final JFwknopTextField userId;
private final JFwknopTextField passphrase;
private final JButton btnSubmit;
public GpgKeySettingsView(JFrame parentWindow) { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopTextField.java
// public class JFwknopTextField extends JTextField implements IFwknopVariable {
//
// private static final long serialVersionUID = 1L;
// private final String defaultVal;
//
// public JFwknopTextField(final String val) {
// super(val);
// this.defaultVal = val;
// this.addFocusListener(new FocusListener() {
// @Override
// public void focusGained(FocusEvent e) {
// }
//
// @Override
// public void focusLost(FocusEvent e) {
// if (((JFwknopTextField) e.getSource()).getText().equals(StringUtils.EMPTY)) {
// setDefaultValue();
// }
// }
// });
// }
//
// @Override
// public void setDefaultValue() {
// this.setText(this.defaultVal);
// }
//
// @Override
// public boolean isDefault() {
// boolean def = false;
// if (this.defaultVal.equals(this.getText())) {
// def = true;
// }
//
// return def;
// }
// }
// Path: src/main/java/com/cipherdyne/gui/gpg/GpgKeySettingsView.java
import com.cipherdyne.utils.InternationalizationHelper;
import com.cipherdyne.gui.components.JFwknopTextField;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.gpg;
/**
*
* @author franck
*/
public class GpgKeySettingsView extends JDialog {
private final JFwknopTextField userId;
private final JFwknopTextField passphrase;
private final JButton btnSubmit;
public GpgKeySettingsView(JFrame parentWindow) { | super(parentWindow, InternationalizationHelper.getMessage("i18n.key.creation"), true); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/wizard/EnumWizardButton.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import com.cipherdyne.utils.InternationalizationHelper; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.wizard;
/**
*
* @author Franck Joncourt
*/
public enum EnumWizardButton {
CANCEL("i18n.wizard.cancel"),
BACK("i18n.wizard.back"),
NEXT("i18n.wizard.next"),
FINISH("i18n.wizard.finish"),
GENERATE_AES_KEY("i18n.wizard.generate.aes.key"),
GENERATE_HMAC_KEY("i18n.wizard.generate.hmac.key"),
BROWSE_FOR_GPG_HOMEDIR("i18n.wizard.browse.for.gpg.homedir"),
CREATE_GPG_HOMEDIR("i18n.wizard.create.gpg.homedir"),
BROWSE_FOR_GPG_SIGNER_ID("i18n.wizard.browse.for.gpg.signerid"),
BROWSE_FOR_GPG_RECIPIENT_ID("i18n.wizard.browse.for.gpg.recipientid");
final private String description;
private EnumWizardButton(String description) {
this.description = description;
}
public String getDescription() { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/gui/wizard/EnumWizardButton.java
import com.cipherdyne.utils.InternationalizationHelper;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.wizard;
/**
*
* @author Franck Joncourt
*/
public enum EnumWizardButton {
CANCEL("i18n.wizard.cancel"),
BACK("i18n.wizard.back"),
NEXT("i18n.wizard.next"),
FINISH("i18n.wizard.finish"),
GENERATE_AES_KEY("i18n.wizard.generate.aes.key"),
GENERATE_HMAC_KEY("i18n.wizard.generate.hmac.key"),
BROWSE_FOR_GPG_HOMEDIR("i18n.wizard.browse.for.gpg.homedir"),
CREATE_GPG_HOMEDIR("i18n.wizard.create.gpg.homedir"),
BROWSE_FOR_GPG_SIGNER_ID("i18n.wizard.browse.for.gpg.signerid"),
BROWSE_FOR_GPG_RECIPIENT_ID("i18n.wizard.browse.for.gpg.recipientid");
final private String description;
private EnumWizardButton(String description) {
this.description = description;
}
public String getDescription() { | return InternationalizationHelper.getMessage(this.description); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/ssh/SshView.java | // Path: src/main/java/com/cipherdyne/gui/components/IFwknopVariable.java
// public interface IFwknopVariable {
// void setText(final String val);
//
// String getText();
//
// void setDefaultValue();
//
// boolean isDefault();
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopLabel.java
// public class JFwknopLabel extends JLabel {
//
// /**
// * JFwknopLabel constructor
// *
// * @param label label to display
// */
// public JFwknopLabel(String label) {
// super(label);
// Border paddingBorder = BorderFactory.createEmptyBorder(0, 2, 0, 2);
// MatteBorder border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray);
// this.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopTextField.java
// public class JFwknopTextField extends JTextField implements IFwknopVariable {
//
// private static final long serialVersionUID = 1L;
// private final String defaultVal;
//
// public JFwknopTextField(final String val) {
// super(val);
// this.defaultVal = val;
// this.addFocusListener(new FocusListener() {
// @Override
// public void focusGained(FocusEvent e) {
// }
//
// @Override
// public void focusLost(FocusEvent e) {
// if (((JFwknopTextField) e.getSource()).getText().equals(StringUtils.EMPTY)) {
// setDefaultValue();
// }
// }
// });
// }
//
// @Override
// public void setDefaultValue() {
// this.setText(this.defaultVal);
// }
//
// @Override
// public boolean isDefault() {
// boolean def = false;
// if (this.defaultVal.equals(this.getText())) {
// def = true;
// }
//
// return def;
// }
// }
| import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
import com.cipherdyne.gui.components.IFwknopVariable;
import com.cipherdyne.utils.InternationalizationHelper;
import com.cipherdyne.gui.components.JFwknopLabel;
import com.cipherdyne.gui.components.JFwknopTextField;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ssh;
/**
* Create a UI to display SSH settings to export a file to a remote server.
*
* @author franck
*/
public class SshView extends JDialog {
private JTable sshFileTable = null;
// SSH settings map that contains username, password as IFwknopVariable | // Path: src/main/java/com/cipherdyne/gui/components/IFwknopVariable.java
// public interface IFwknopVariable {
// void setText(final String val);
//
// String getText();
//
// void setDefaultValue();
//
// boolean isDefault();
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopLabel.java
// public class JFwknopLabel extends JLabel {
//
// /**
// * JFwknopLabel constructor
// *
// * @param label label to display
// */
// public JFwknopLabel(String label) {
// super(label);
// Border paddingBorder = BorderFactory.createEmptyBorder(0, 2, 0, 2);
// MatteBorder border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray);
// this.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopTextField.java
// public class JFwknopTextField extends JTextField implements IFwknopVariable {
//
// private static final long serialVersionUID = 1L;
// private final String defaultVal;
//
// public JFwknopTextField(final String val) {
// super(val);
// this.defaultVal = val;
// this.addFocusListener(new FocusListener() {
// @Override
// public void focusGained(FocusEvent e) {
// }
//
// @Override
// public void focusLost(FocusEvent e) {
// if (((JFwknopTextField) e.getSource()).getText().equals(StringUtils.EMPTY)) {
// setDefaultValue();
// }
// }
// });
// }
//
// @Override
// public void setDefaultValue() {
// this.setText(this.defaultVal);
// }
//
// @Override
// public boolean isDefault() {
// boolean def = false;
// if (this.defaultVal.equals(this.getText())) {
// def = true;
// }
//
// return def;
// }
// }
// Path: src/main/java/com/cipherdyne/gui/ssh/SshView.java
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
import com.cipherdyne.gui.components.IFwknopVariable;
import com.cipherdyne.utils.InternationalizationHelper;
import com.cipherdyne.gui.components.JFwknopLabel;
import com.cipherdyne.gui.components.JFwknopTextField;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ssh;
/**
* Create a UI to display SSH settings to export a file to a remote server.
*
* @author franck
*/
public class SshView extends JDialog {
private JTable sshFileTable = null;
// SSH settings map that contains username, password as IFwknopVariable | private final Map<EnumSshSettings, IFwknopVariable> settingsMap = new HashMap<>(); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/ssh/SshView.java | // Path: src/main/java/com/cipherdyne/gui/components/IFwknopVariable.java
// public interface IFwknopVariable {
// void setText(final String val);
//
// String getText();
//
// void setDefaultValue();
//
// boolean isDefault();
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopLabel.java
// public class JFwknopLabel extends JLabel {
//
// /**
// * JFwknopLabel constructor
// *
// * @param label label to display
// */
// public JFwknopLabel(String label) {
// super(label);
// Border paddingBorder = BorderFactory.createEmptyBorder(0, 2, 0, 2);
// MatteBorder border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray);
// this.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopTextField.java
// public class JFwknopTextField extends JTextField implements IFwknopVariable {
//
// private static final long serialVersionUID = 1L;
// private final String defaultVal;
//
// public JFwknopTextField(final String val) {
// super(val);
// this.defaultVal = val;
// this.addFocusListener(new FocusListener() {
// @Override
// public void focusGained(FocusEvent e) {
// }
//
// @Override
// public void focusLost(FocusEvent e) {
// if (((JFwknopTextField) e.getSource()).getText().equals(StringUtils.EMPTY)) {
// setDefaultValue();
// }
// }
// });
// }
//
// @Override
// public void setDefaultValue() {
// this.setText(this.defaultVal);
// }
//
// @Override
// public boolean isDefault() {
// boolean def = false;
// if (this.defaultVal.equals(this.getText())) {
// def = true;
// }
//
// return def;
// }
// }
| import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
import com.cipherdyne.gui.components.IFwknopVariable;
import com.cipherdyne.utils.InternationalizationHelper;
import com.cipherdyne.gui.components.JFwknopLabel;
import com.cipherdyne.gui.components.JFwknopTextField;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ssh;
/**
* Create a UI to display SSH settings to export a file to a remote server.
*
* @author franck
*/
public class SshView extends JDialog {
private JTable sshFileTable = null;
// SSH settings map that contains username, password as IFwknopVariable
private final Map<EnumSshSettings, IFwknopVariable> settingsMap = new HashMap<>();
// Browse button to look for the file to send
private final JButton btnAddFile;
// Browse button to look for the file to send
private final JButton btnRemoveFile;
// Button used to perform the export action
private final JButton btnExport;
/**
* Create a SSH view that provide SSH settings used to connect to a remote SSH server and copy
* local file to it
*
* @param frame parent frame
*/
public SshView(JFrame frame) { | // Path: src/main/java/com/cipherdyne/gui/components/IFwknopVariable.java
// public interface IFwknopVariable {
// void setText(final String val);
//
// String getText();
//
// void setDefaultValue();
//
// boolean isDefault();
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopLabel.java
// public class JFwknopLabel extends JLabel {
//
// /**
// * JFwknopLabel constructor
// *
// * @param label label to display
// */
// public JFwknopLabel(String label) {
// super(label);
// Border paddingBorder = BorderFactory.createEmptyBorder(0, 2, 0, 2);
// MatteBorder border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray);
// this.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopTextField.java
// public class JFwknopTextField extends JTextField implements IFwknopVariable {
//
// private static final long serialVersionUID = 1L;
// private final String defaultVal;
//
// public JFwknopTextField(final String val) {
// super(val);
// this.defaultVal = val;
// this.addFocusListener(new FocusListener() {
// @Override
// public void focusGained(FocusEvent e) {
// }
//
// @Override
// public void focusLost(FocusEvent e) {
// if (((JFwknopTextField) e.getSource()).getText().equals(StringUtils.EMPTY)) {
// setDefaultValue();
// }
// }
// });
// }
//
// @Override
// public void setDefaultValue() {
// this.setText(this.defaultVal);
// }
//
// @Override
// public boolean isDefault() {
// boolean def = false;
// if (this.defaultVal.equals(this.getText())) {
// def = true;
// }
//
// return def;
// }
// }
// Path: src/main/java/com/cipherdyne/gui/ssh/SshView.java
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
import com.cipherdyne.gui.components.IFwknopVariable;
import com.cipherdyne.utils.InternationalizationHelper;
import com.cipherdyne.gui.components.JFwknopLabel;
import com.cipherdyne.gui.components.JFwknopTextField;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ssh;
/**
* Create a UI to display SSH settings to export a file to a remote server.
*
* @author franck
*/
public class SshView extends JDialog {
private JTable sshFileTable = null;
// SSH settings map that contains username, password as IFwknopVariable
private final Map<EnumSshSettings, IFwknopVariable> settingsMap = new HashMap<>();
// Browse button to look for the file to send
private final JButton btnAddFile;
// Browse button to look for the file to send
private final JButton btnRemoveFile;
// Button used to perform the export action
private final JButton btnExport;
/**
* Create a SSH view that provide SSH settings used to connect to a remote SSH server and copy
* local file to it
*
* @param frame parent frame
*/
public SshView(JFrame frame) { | super(frame, InternationalizationHelper.getMessage("i18n.ssh.export.title"), true); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/ssh/SshView.java | // Path: src/main/java/com/cipherdyne/gui/components/IFwknopVariable.java
// public interface IFwknopVariable {
// void setText(final String val);
//
// String getText();
//
// void setDefaultValue();
//
// boolean isDefault();
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopLabel.java
// public class JFwknopLabel extends JLabel {
//
// /**
// * JFwknopLabel constructor
// *
// * @param label label to display
// */
// public JFwknopLabel(String label) {
// super(label);
// Border paddingBorder = BorderFactory.createEmptyBorder(0, 2, 0, 2);
// MatteBorder border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray);
// this.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopTextField.java
// public class JFwknopTextField extends JTextField implements IFwknopVariable {
//
// private static final long serialVersionUID = 1L;
// private final String defaultVal;
//
// public JFwknopTextField(final String val) {
// super(val);
// this.defaultVal = val;
// this.addFocusListener(new FocusListener() {
// @Override
// public void focusGained(FocusEvent e) {
// }
//
// @Override
// public void focusLost(FocusEvent e) {
// if (((JFwknopTextField) e.getSource()).getText().equals(StringUtils.EMPTY)) {
// setDefaultValue();
// }
// }
// });
// }
//
// @Override
// public void setDefaultValue() {
// this.setText(this.defaultVal);
// }
//
// @Override
// public boolean isDefault() {
// boolean def = false;
// if (this.defaultVal.equals(this.getText())) {
// def = true;
// }
//
// return def;
// }
// }
| import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
import com.cipherdyne.gui.components.IFwknopVariable;
import com.cipherdyne.utils.InternationalizationHelper;
import com.cipherdyne.gui.components.JFwknopLabel;
import com.cipherdyne.gui.components.JFwknopTextField;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ssh;
/**
* Create a UI to display SSH settings to export a file to a remote server.
*
* @author franck
*/
public class SshView extends JDialog {
private JTable sshFileTable = null;
// SSH settings map that contains username, password as IFwknopVariable
private final Map<EnumSshSettings, IFwknopVariable> settingsMap = new HashMap<>();
// Browse button to look for the file to send
private final JButton btnAddFile;
// Browse button to look for the file to send
private final JButton btnRemoveFile;
// Button used to perform the export action
private final JButton btnExport;
/**
* Create a SSH view that provide SSH settings used to connect to a remote SSH server and copy
* local file to it
*
* @param frame parent frame
*/
public SshView(JFrame frame) {
super(frame, InternationalizationHelper.getMessage("i18n.ssh.export.title"), true);
// Create file table
sshFileTable = new JTable(new SshFileTableModel());
sshFileTable.setFillsViewportHeight(true);
sshFileTable.setAutoCreateRowSorter(true);
sshFileTable.getColumnModel().getColumn(SshFileTableModel.FILENAME_COL_ID).setMinWidth(300);
// Create components | // Path: src/main/java/com/cipherdyne/gui/components/IFwknopVariable.java
// public interface IFwknopVariable {
// void setText(final String val);
//
// String getText();
//
// void setDefaultValue();
//
// boolean isDefault();
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopLabel.java
// public class JFwknopLabel extends JLabel {
//
// /**
// * JFwknopLabel constructor
// *
// * @param label label to display
// */
// public JFwknopLabel(String label) {
// super(label);
// Border paddingBorder = BorderFactory.createEmptyBorder(0, 2, 0, 2);
// MatteBorder border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray);
// this.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
// }
// }
//
// Path: src/main/java/com/cipherdyne/gui/components/JFwknopTextField.java
// public class JFwknopTextField extends JTextField implements IFwknopVariable {
//
// private static final long serialVersionUID = 1L;
// private final String defaultVal;
//
// public JFwknopTextField(final String val) {
// super(val);
// this.defaultVal = val;
// this.addFocusListener(new FocusListener() {
// @Override
// public void focusGained(FocusEvent e) {
// }
//
// @Override
// public void focusLost(FocusEvent e) {
// if (((JFwknopTextField) e.getSource()).getText().equals(StringUtils.EMPTY)) {
// setDefaultValue();
// }
// }
// });
// }
//
// @Override
// public void setDefaultValue() {
// this.setText(this.defaultVal);
// }
//
// @Override
// public boolean isDefault() {
// boolean def = false;
// if (this.defaultVal.equals(this.getText())) {
// def = true;
// }
//
// return def;
// }
// }
// Path: src/main/java/com/cipherdyne/gui/ssh/SshView.java
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
import com.cipherdyne.gui.components.IFwknopVariable;
import com.cipherdyne.utils.InternationalizationHelper;
import com.cipherdyne.gui.components.JFwknopLabel;
import com.cipherdyne.gui.components.JFwknopTextField;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ssh;
/**
* Create a UI to display SSH settings to export a file to a remote server.
*
* @author franck
*/
public class SshView extends JDialog {
private JTable sshFileTable = null;
// SSH settings map that contains username, password as IFwknopVariable
private final Map<EnumSshSettings, IFwknopVariable> settingsMap = new HashMap<>();
// Browse button to look for the file to send
private final JButton btnAddFile;
// Browse button to look for the file to send
private final JButton btnRemoveFile;
// Button used to perform the export action
private final JButton btnExport;
/**
* Create a SSH view that provide SSH settings used to connect to a remote SSH server and copy
* local file to it
*
* @param frame parent frame
*/
public SshView(JFrame frame) {
super(frame, InternationalizationHelper.getMessage("i18n.ssh.export.title"), true);
// Create file table
sshFileTable = new JTable(new SshFileTableModel());
sshFileTable.setFillsViewportHeight(true);
sshFileTable.setAutoCreateRowSorter(true);
sshFileTable.getColumnModel().getColumn(SshFileTableModel.FILENAME_COL_ID).setMinWidth(300);
// Create components | this.settingsMap.put(EnumSshSettings.USERNAME, new JFwknopTextField("<username>")); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/gpg/GpgView.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import javax.swing.border.TitledBorder;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.openpgp.PGPException;
import com.cipherdyne.utils.InternationalizationHelper;
import java.awt.Font;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.gpg;
/**
* Create a UI to display GPG keys along with their user ids in a modal window.
*/
public class GpgView extends JDialog {
// Button used to select a key
final private JButton btnSelect;
// Button used to cancel the action and go back to the main window
final private JButton btnCancel;
// Button used to export the selected key
final private JButton btnExport;
// Button used to import a key
final private JButton btnImport;
// Button used to remove a key
final private JButton btnRemove;
// Button used to create a new key (public and private)
final private JButton btnCreate;
// Table that displays all keys from the keyring
private JTable keyTable = null;
public GpgView(JFrame frame, String gpgHomeDirectory) { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/gui/gpg/GpgView.java
import javax.swing.border.TitledBorder;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.openpgp.PGPException;
import com.cipherdyne.utils.InternationalizationHelper;
import java.awt.Font;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.gpg;
/**
* Create a UI to display GPG keys along with their user ids in a modal window.
*/
public class GpgView extends JDialog {
// Button used to select a key
final private JButton btnSelect;
// Button used to cancel the action and go back to the main window
final private JButton btnCancel;
// Button used to export the selected key
final private JButton btnExport;
// Button used to import a key
final private JButton btnImport;
// Button used to remove a key
final private JButton btnRemove;
// Button used to create a new key (public and private)
final private JButton btnCreate;
// Table that displays all keys from the keyring
private JTable keyTable = null;
public GpgView(JFrame frame, String gpgHomeDirectory) { | super(frame, InternationalizationHelper.getMessage("i18n.key.management"), true); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/ip/IpView.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import com.cipherdyne.utils.InternationalizationHelper;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ip;
/**
* Create a UI to display network interfaces in a modal window.
*/
public class IpView extends JDialog {
// Cancel button to close the window without selected any IP addresses
private final JButton btnCancel;
// Select button to update the main window with the IP addresses currently highlighted
private final JButton btnSelect;
// Table that displays all network interfaces
private JTable intfTable = null;
public IpView(JFrame frame) { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/gui/ip/IpView.java
import com.cipherdyne.utils.InternationalizationHelper;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.ip;
/**
* Create a UI to display network interfaces in a modal window.
*/
public class IpView extends JDialog {
// Cancel button to close the window without selected any IP addresses
private final JButton btnCancel;
// Select button to update the main window with the IP addresses currently highlighted
private final JButton btnSelect;
// Table that displays all network interfaces
private JTable intfTable = null;
public IpView(JFrame frame) { | super(frame, InternationalizationHelper.getMessage("i18n.ip.management"), true); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/jfwknop/EnumFwknopRcKey.java | // Path: src/main/java/com/cipherdyne/jfwknop/EnumFwknopRcType.java
// public enum EnumFwknopRcType {
//
// PORT_LIST,
// IP_ADDRESS,
// LOCAL_IP_ADDRESS,
// Y_N,
// DIGEST_ALGORITHM,
// ENCRYPT_MODE,
// PASSPHRASE,
// BASE64_PASSPHRASE,
// GPG_KEY_ID,
// DIRECTORY_PATH,
// FILE_PATH,
// IP_PLUS_PORT,
// SINGLE_PORT,
// PROTOCOL,
// PROTOCOL_PLUS_PORT,
// SECONDS,
// URL,
// STRING,
// TIME;
//
// private EnumFwknopRcType() {
// }
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import static com.cipherdyne.jfwknop.EnumFwknopRcType.*;
import com.cipherdyne.utils.InternationalizationHelper; | SPOOF_USER(STRING, "i18n.spa.spoof.user"),
SPOOF_SOURCE_IP(IP_ADDRESS, "i18n.spa.spoof.source.ip"),
RAND_PORT(Y_N, "i18n.spa.random.source.port"),
KEY_FILE(FILE_PATH, ""),
HTTP_USER_AGENT(STRING, ""),
NAT_ACCESS(IP_PLUS_PORT, "i18n.nat.access.ip"),
NAT_LOCAL(Y_N, "i18n.nat.local"),
NAT_PORT(SINGLE_PORT, "i18n.nat.port"),
NAT_RAND_PORT(Y_N, "i18n.nat.rand.port"),
SPA_SERVER(IP_ADDRESS, "i18n.spa.server.ip"),
SPA_SERVER_PORT(SINGLE_PORT, "i18n.spa.server.port"),
SPA_SERVER_PROTO(PROTOCOL, "i18n.spa.client.proto"),
KEY(PASSPHRASE, "i18n.rijndael.key", EnumFwknopdRcKey.KEY),
KEY_BASE64(BASE64_PASSPHRASE, "i18n.rijndael.keybase64", EnumFwknopdRcKey.KEY_BASE64),
USE_HMAC(Y_N, "i18n.hmac.use"),
HMAC_KEY(PASSPHRASE, "i18n.hmac.key", EnumFwknopdRcKey.HMAC_KEY),
HMAC_KEY_BASE64(BASE64_PASSPHRASE, "i18n.hmac.key.base64", EnumFwknopdRcKey.HMAC_KEY_BASE64),
HMAC_DIGEST_TYPE(DIGEST_ALGORITHM, "i18n.hmac.digest.type", EnumFwknopdRcKey.HMAC_DIGEST_TYPE),
SPA_SOURCE_PORT(SINGLE_PORT, "i18n.spa.client.sourceport"),
FW_TIMEOUT(SECONDS, "i18n.misc.timeout"),
RESOLVE_IP_HTTPS(Y_N, "i18n.resolve.ip.https"),
RESOLVE_HTTP_ONLY(Y_N, "i18n.resolve.ip.http.only"),
RESOLVE_URL(URL, "i18n.spa.client.resolveurl"),
SERVER_RESOLVE_IPV4(Y_N, "i18n.spa.server.resolve.ipv4"),
TIME_OFFSET(TIME, "i18n.misc.timeoffset");
| // Path: src/main/java/com/cipherdyne/jfwknop/EnumFwknopRcType.java
// public enum EnumFwknopRcType {
//
// PORT_LIST,
// IP_ADDRESS,
// LOCAL_IP_ADDRESS,
// Y_N,
// DIGEST_ALGORITHM,
// ENCRYPT_MODE,
// PASSPHRASE,
// BASE64_PASSPHRASE,
// GPG_KEY_ID,
// DIRECTORY_PATH,
// FILE_PATH,
// IP_PLUS_PORT,
// SINGLE_PORT,
// PROTOCOL,
// PROTOCOL_PLUS_PORT,
// SECONDS,
// URL,
// STRING,
// TIME;
//
// private EnumFwknopRcType() {
// }
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/jfwknop/EnumFwknopRcKey.java
import static com.cipherdyne.jfwknop.EnumFwknopRcType.*;
import com.cipherdyne.utils.InternationalizationHelper;
SPOOF_USER(STRING, "i18n.spa.spoof.user"),
SPOOF_SOURCE_IP(IP_ADDRESS, "i18n.spa.spoof.source.ip"),
RAND_PORT(Y_N, "i18n.spa.random.source.port"),
KEY_FILE(FILE_PATH, ""),
HTTP_USER_AGENT(STRING, ""),
NAT_ACCESS(IP_PLUS_PORT, "i18n.nat.access.ip"),
NAT_LOCAL(Y_N, "i18n.nat.local"),
NAT_PORT(SINGLE_PORT, "i18n.nat.port"),
NAT_RAND_PORT(Y_N, "i18n.nat.rand.port"),
SPA_SERVER(IP_ADDRESS, "i18n.spa.server.ip"),
SPA_SERVER_PORT(SINGLE_PORT, "i18n.spa.server.port"),
SPA_SERVER_PROTO(PROTOCOL, "i18n.spa.client.proto"),
KEY(PASSPHRASE, "i18n.rijndael.key", EnumFwknopdRcKey.KEY),
KEY_BASE64(BASE64_PASSPHRASE, "i18n.rijndael.keybase64", EnumFwknopdRcKey.KEY_BASE64),
USE_HMAC(Y_N, "i18n.hmac.use"),
HMAC_KEY(PASSPHRASE, "i18n.hmac.key", EnumFwknopdRcKey.HMAC_KEY),
HMAC_KEY_BASE64(BASE64_PASSPHRASE, "i18n.hmac.key.base64", EnumFwknopdRcKey.HMAC_KEY_BASE64),
HMAC_DIGEST_TYPE(DIGEST_ALGORITHM, "i18n.hmac.digest.type", EnumFwknopdRcKey.HMAC_DIGEST_TYPE),
SPA_SOURCE_PORT(SINGLE_PORT, "i18n.spa.client.sourceport"),
FW_TIMEOUT(SECONDS, "i18n.misc.timeout"),
RESOLVE_IP_HTTPS(Y_N, "i18n.resolve.ip.https"),
RESOLVE_HTTP_ONLY(Y_N, "i18n.resolve.ip.http.only"),
RESOLVE_URL(URL, "i18n.spa.client.resolveurl"),
SERVER_RESOLVE_IPV4(Y_N, "i18n.spa.server.resolve.ipv4"),
TIME_OFFSET(TIME, "i18n.misc.timeoffset");
| final private EnumFwknopRcType type; |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/jfwknop/EnumFwknopRcKey.java | // Path: src/main/java/com/cipherdyne/jfwknop/EnumFwknopRcType.java
// public enum EnumFwknopRcType {
//
// PORT_LIST,
// IP_ADDRESS,
// LOCAL_IP_ADDRESS,
// Y_N,
// DIGEST_ALGORITHM,
// ENCRYPT_MODE,
// PASSPHRASE,
// BASE64_PASSPHRASE,
// GPG_KEY_ID,
// DIRECTORY_PATH,
// FILE_PATH,
// IP_PLUS_PORT,
// SINGLE_PORT,
// PROTOCOL,
// PROTOCOL_PLUS_PORT,
// SECONDS,
// URL,
// STRING,
// TIME;
//
// private EnumFwknopRcType() {
// }
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import static com.cipherdyne.jfwknop.EnumFwknopRcType.*;
import com.cipherdyne.utils.InternationalizationHelper; |
SPA_SOURCE_PORT(SINGLE_PORT, "i18n.spa.client.sourceport"),
FW_TIMEOUT(SECONDS, "i18n.misc.timeout"),
RESOLVE_IP_HTTPS(Y_N, "i18n.resolve.ip.https"),
RESOLVE_HTTP_ONLY(Y_N, "i18n.resolve.ip.http.only"),
RESOLVE_URL(URL, "i18n.spa.client.resolveurl"),
SERVER_RESOLVE_IPV4(Y_N, "i18n.spa.server.resolve.ipv4"),
TIME_OFFSET(TIME, "i18n.misc.timeoffset");
final private EnumFwknopRcType type;
final private String i18Label;
final private EnumFwknopdRcKey remoteKey;
private EnumFwknopRcKey(EnumFwknopRcType type, String i18label) {
this.type = type;
this.i18Label = i18label;
this.remoteKey = null;
}
private EnumFwknopRcKey(EnumFwknopRcType type, String i18label, EnumFwknopdRcKey remoteKey) {
this.type = type;
this.i18Label = i18label;
this.remoteKey = remoteKey;
}
public EnumFwknopRcType getType() {
return this.type;
}
public String getLabel() { | // Path: src/main/java/com/cipherdyne/jfwknop/EnumFwknopRcType.java
// public enum EnumFwknopRcType {
//
// PORT_LIST,
// IP_ADDRESS,
// LOCAL_IP_ADDRESS,
// Y_N,
// DIGEST_ALGORITHM,
// ENCRYPT_MODE,
// PASSPHRASE,
// BASE64_PASSPHRASE,
// GPG_KEY_ID,
// DIRECTORY_PATH,
// FILE_PATH,
// IP_PLUS_PORT,
// SINGLE_PORT,
// PROTOCOL,
// PROTOCOL_PLUS_PORT,
// SECONDS,
// URL,
// STRING,
// TIME;
//
// private EnumFwknopRcType() {
// }
// }
//
// Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/jfwknop/EnumFwknopRcKey.java
import static com.cipherdyne.jfwknop.EnumFwknopRcType.*;
import com.cipherdyne.utils.InternationalizationHelper;
SPA_SOURCE_PORT(SINGLE_PORT, "i18n.spa.client.sourceport"),
FW_TIMEOUT(SECONDS, "i18n.misc.timeout"),
RESOLVE_IP_HTTPS(Y_N, "i18n.resolve.ip.https"),
RESOLVE_HTTP_ONLY(Y_N, "i18n.resolve.ip.http.only"),
RESOLVE_URL(URL, "i18n.spa.client.resolveurl"),
SERVER_RESOLVE_IPV4(Y_N, "i18n.spa.server.resolve.ipv4"),
TIME_OFFSET(TIME, "i18n.misc.timeoffset");
final private EnumFwknopRcType type;
final private String i18Label;
final private EnumFwknopdRcKey remoteKey;
private EnumFwknopRcKey(EnumFwknopRcType type, String i18label) {
this.type = type;
this.i18Label = i18label;
this.remoteKey = null;
}
private EnumFwknopRcKey(EnumFwknopRcType type, String i18label, EnumFwknopdRcKey remoteKey) {
this.type = type;
this.i18Label = i18label;
this.remoteKey = remoteKey;
}
public EnumFwknopRcType getType() {
return this.type;
}
public String getLabel() { | return InternationalizationHelper.getMessage(this.i18Label); |
fjoncourt/jfwknop | src/main/java/com/cipherdyne/gui/wizard/EnumWizardVariable.java | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
| import com.cipherdyne.utils.InternationalizationHelper; | /*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.wizard;
/**
*
* @author Franck Joncourt
*/
public enum EnumWizardVariable {
ENCRYPTION_MODE("i18n.wizard.encryptionmode.description"),
AES_KEY("i18n.wizard.key.description"),
HMAC_KEY("i18n.wizard.hmac.description"),
REMOTE_HOST("i18n.wizard.remotehost.description"),
ACCESS("i18n.wizard.access.description"),
GPG_HOME_DIRECTORY("i18n.wizard.gnupg.homedirectory.description"),
GPG_SIGNER_ID("i18n.wizard.gnupg.signerid.description"),
GPG_SIGNER_PASSWORD("i18n.wizard.gnupg.signerid.password"),
GPG_RECIPIENT_ID("i18n.wizard.gnupg.recipientid.description");
private final String description;
private EnumWizardVariable(String description) {
this.description = description;
}
public String getDescription() { | // Path: src/main/java/com/cipherdyne/utils/InternationalizationHelper.java
// public class InternationalizationHelper {
//
// static private ResourceBundle messages;
// private static final Logger LOGGER = LogManager.getLogger(InternationalizationHelper.class.getName());
// private static InternationalizationHelper instance = null;
//
// /**
// * Hidden constructor
// *
// * @param language
// * @param country
// */
// private InternationalizationHelper(final String language, final String country) {
//
// messages = ResourceBundle.getBundle("messages", new Locale(language, country));
// }
//
// public static String getMessage(final String i18nKey) {
//
// String translation = i18nKey;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
// LOGGER.warn("No translation found for key " + i18nKey);
// }
//
// return translation;
// }
//
// public static String getMessageOrNull(final String i18nKey) {
//
// String translation = null;
//
// if (instance == null) {
// instance = new InternationalizationHelper("en", "EN");
// }
//
// try {
// translation = messages.getString(i18nKey);
// } catch (final MissingResourceException e) {
//
// }
//
// return translation;
// }
//
// public static void configure(final String locale) {
// String[] localeArray = locale.split("_");
// instance = new InternationalizationHelper(localeArray[0], localeArray[1]);
// }
// }
// Path: src/main/java/com/cipherdyne/gui/wizard/EnumWizardVariable.java
import com.cipherdyne.utils.InternationalizationHelper;
/*
* JFwknop is developed primarily by the people listed in the file 'AUTHORS'.
* Copyright (C) 2016 JFwknop developers and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.cipherdyne.gui.wizard;
/**
*
* @author Franck Joncourt
*/
public enum EnumWizardVariable {
ENCRYPTION_MODE("i18n.wizard.encryptionmode.description"),
AES_KEY("i18n.wizard.key.description"),
HMAC_KEY("i18n.wizard.hmac.description"),
REMOTE_HOST("i18n.wizard.remotehost.description"),
ACCESS("i18n.wizard.access.description"),
GPG_HOME_DIRECTORY("i18n.wizard.gnupg.homedirectory.description"),
GPG_SIGNER_ID("i18n.wizard.gnupg.signerid.description"),
GPG_SIGNER_PASSWORD("i18n.wizard.gnupg.signerid.password"),
GPG_RECIPIENT_ID("i18n.wizard.gnupg.recipientid.description");
private final String description;
private EnumWizardVariable(String description) {
this.description = description;
}
public String getDescription() { | return InternationalizationHelper.getMessage(this.description); |
quanhua92/GLMediaPlayer | gltoolkit/src/main/java/com/quan404/gltoolkit/programs/ShaderProgram.java | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/ShaderHelper.java
// public class ShaderHelper {
// private static final String TAG = "ShaderHelper";
//
// public static int compileVertexShader(String code){
// return compileShader(GLES20.GL_VERTEX_SHADER, code);
// }
//
// public static int compileFragmentShader(String code){
// return compileShader(GLES20.GL_FRAGMENT_SHADER, code);
// }
//
// private static int compileShader(int type, String code){
// final int shaderObjectId = GLES20.glCreateShader(type);
//
// if (shaderObjectId == 0){
// if (LoggerConfig.ON){
// Log.w(TAG, "Could not create new shader");
// }
// return 0;
// }
//
// GLES20.glShaderSource(shaderObjectId, code);
// GLES20.glCompileShader(shaderObjectId);
//
// final int[] compileStatus = new int[1];
// GLES20.glGetShaderiv(shaderObjectId, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
//
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of compiling source: " + "\n" + code + "\n" + GLES20.glGetShaderInfoLog(shaderObjectId));
// }
//
// if (compileStatus[0] == 0){
// // if it failed, delete the shader object
// GLES20.glDeleteShader(shaderObjectId);
//
// if (LoggerConfig.ON){
// Log.w(TAG, "Compilation of shader failed");
// }
// return 0;
// }
// return shaderObjectId;
// }
//
// public static int linkProgram(int vertexShaderId, int fragmentShaderId){
// final int programObjectId = GLES20.glCreateProgram();
//
// if(programObjectId == 0){
// if (LoggerConfig.ON){
// Log.w(TAG, "Could not create new program");
// }
// return 0;
// }
//
// GLES20.glAttachShader(programObjectId, vertexShaderId);
// GLES20.glAttachShader(programObjectId, fragmentShaderId);
//
// GLES20.glLinkProgram(programObjectId);
//
// final int[] linkStatus = new int[1];
// GLES20.glGetProgramiv(programObjectId, GLES20.GL_LINK_STATUS, linkStatus, 0);
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of linking program: " + "\n" + GLES20.glGetProgramInfoLog(programObjectId));
// }
//
// if (linkStatus[0] == 0){
// // if it failed, delete the shader object
// GLES20.glDeleteProgram(programObjectId);
//
// if (LoggerConfig.ON){
// Log.w(TAG, "Linking of program failed");
// }
// return 0;
// }
// return programObjectId;
// }
//
// public static boolean validateProgram(int programObjectId) {
// GLES20.glValidateProgram(programObjectId);
//
// final int[] validateStatus = new int[1];
// GLES20.glGetProgramiv(programObjectId, GLES20.GL_VALIDATE_STATUS, validateStatus, 0);
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of validating program: " + validateStatus[0] + "\nLog: " + GLES20.glGetProgramInfoLog(programObjectId));
// }
// return validateStatus[0] != 0;
// }
//
// public static int buildProgram(String vertexShaderSource, String fragmentShaderSource){
// int program;
//
// // compile the shaders
// int vertexShader = compileVertexShader(vertexShaderSource);
// int fragmentShader = compileFragmentShader(fragmentShaderSource);
//
// // link them into a shader program
// program = linkProgram(vertexShader, fragmentShader);
//
// if (LoggerConfig.ON){
// validateProgram(program);
// }
//
// return program;
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/TextResourceReader.java
// public class TextResourceReader {
// public static String readTextFileFromResource(Context context, int resourceId) {
// StringBuilder body = new StringBuilder();
//
// try{
// InputStream inputStream = context.getResources().openRawResource(resourceId);
// InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
//
// BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
//
// String nextLine;
//
// while ((nextLine = bufferedReader.readLine()) != null){
// body.append(nextLine);
// body.append("\n");
// }
// }catch (IOException e){
// throw new RuntimeException("Could not open resource: " + resourceId, e);
// } catch (Resources.NotFoundException nfe){
// throw new RuntimeException("Resource not found: " + resourceId, nfe);
// }
//
// return body.toString();
// }
// }
| import android.content.Context;
import android.opengl.GLES20;
import android.util.Log;
import com.quan404.gltoolkit.ShaderHelper;
import com.quan404.gltoolkit.TextResourceReader; | package com.quan404.gltoolkit.programs;
/**
* Created by quanhua on 05/01/2016.
*/
abstract class ShaderProgram {
// Uniform constants
protected static final String U_MATRIX = "u_Matrix";
protected static final String U_TEXTURE_UNIT = "u_TextureUnit";
protected static final String U_COLOR = "u_Color";
protected static final String U_MVPMATRIX = "u_MVPMatrix";
protected static final String U_STMATRIX = "u_STMatrix";
// Attribute constants
protected static final String A_POSITION = "a_Position";
protected static final String A_COLOR = "a_Color";
protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
// Shader program
protected final int program;
protected ShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) { | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/ShaderHelper.java
// public class ShaderHelper {
// private static final String TAG = "ShaderHelper";
//
// public static int compileVertexShader(String code){
// return compileShader(GLES20.GL_VERTEX_SHADER, code);
// }
//
// public static int compileFragmentShader(String code){
// return compileShader(GLES20.GL_FRAGMENT_SHADER, code);
// }
//
// private static int compileShader(int type, String code){
// final int shaderObjectId = GLES20.glCreateShader(type);
//
// if (shaderObjectId == 0){
// if (LoggerConfig.ON){
// Log.w(TAG, "Could not create new shader");
// }
// return 0;
// }
//
// GLES20.glShaderSource(shaderObjectId, code);
// GLES20.glCompileShader(shaderObjectId);
//
// final int[] compileStatus = new int[1];
// GLES20.glGetShaderiv(shaderObjectId, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
//
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of compiling source: " + "\n" + code + "\n" + GLES20.glGetShaderInfoLog(shaderObjectId));
// }
//
// if (compileStatus[0] == 0){
// // if it failed, delete the shader object
// GLES20.glDeleteShader(shaderObjectId);
//
// if (LoggerConfig.ON){
// Log.w(TAG, "Compilation of shader failed");
// }
// return 0;
// }
// return shaderObjectId;
// }
//
// public static int linkProgram(int vertexShaderId, int fragmentShaderId){
// final int programObjectId = GLES20.glCreateProgram();
//
// if(programObjectId == 0){
// if (LoggerConfig.ON){
// Log.w(TAG, "Could not create new program");
// }
// return 0;
// }
//
// GLES20.glAttachShader(programObjectId, vertexShaderId);
// GLES20.glAttachShader(programObjectId, fragmentShaderId);
//
// GLES20.glLinkProgram(programObjectId);
//
// final int[] linkStatus = new int[1];
// GLES20.glGetProgramiv(programObjectId, GLES20.GL_LINK_STATUS, linkStatus, 0);
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of linking program: " + "\n" + GLES20.glGetProgramInfoLog(programObjectId));
// }
//
// if (linkStatus[0] == 0){
// // if it failed, delete the shader object
// GLES20.glDeleteProgram(programObjectId);
//
// if (LoggerConfig.ON){
// Log.w(TAG, "Linking of program failed");
// }
// return 0;
// }
// return programObjectId;
// }
//
// public static boolean validateProgram(int programObjectId) {
// GLES20.glValidateProgram(programObjectId);
//
// final int[] validateStatus = new int[1];
// GLES20.glGetProgramiv(programObjectId, GLES20.GL_VALIDATE_STATUS, validateStatus, 0);
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of validating program: " + validateStatus[0] + "\nLog: " + GLES20.glGetProgramInfoLog(programObjectId));
// }
// return validateStatus[0] != 0;
// }
//
// public static int buildProgram(String vertexShaderSource, String fragmentShaderSource){
// int program;
//
// // compile the shaders
// int vertexShader = compileVertexShader(vertexShaderSource);
// int fragmentShader = compileFragmentShader(fragmentShaderSource);
//
// // link them into a shader program
// program = linkProgram(vertexShader, fragmentShader);
//
// if (LoggerConfig.ON){
// validateProgram(program);
// }
//
// return program;
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/TextResourceReader.java
// public class TextResourceReader {
// public static String readTextFileFromResource(Context context, int resourceId) {
// StringBuilder body = new StringBuilder();
//
// try{
// InputStream inputStream = context.getResources().openRawResource(resourceId);
// InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
//
// BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
//
// String nextLine;
//
// while ((nextLine = bufferedReader.readLine()) != null){
// body.append(nextLine);
// body.append("\n");
// }
// }catch (IOException e){
// throw new RuntimeException("Could not open resource: " + resourceId, e);
// } catch (Resources.NotFoundException nfe){
// throw new RuntimeException("Resource not found: " + resourceId, nfe);
// }
//
// return body.toString();
// }
// }
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/programs/ShaderProgram.java
import android.content.Context;
import android.opengl.GLES20;
import android.util.Log;
import com.quan404.gltoolkit.ShaderHelper;
import com.quan404.gltoolkit.TextResourceReader;
package com.quan404.gltoolkit.programs;
/**
* Created by quanhua on 05/01/2016.
*/
abstract class ShaderProgram {
// Uniform constants
protected static final String U_MATRIX = "u_Matrix";
protected static final String U_TEXTURE_UNIT = "u_TextureUnit";
protected static final String U_COLOR = "u_Color";
protected static final String U_MVPMATRIX = "u_MVPMatrix";
protected static final String U_STMATRIX = "u_STMatrix";
// Attribute constants
protected static final String A_POSITION = "a_Position";
protected static final String A_COLOR = "a_Color";
protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
// Shader program
protected final int program;
protected ShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) { | program = ShaderHelper.buildProgram( |
quanhua92/GLMediaPlayer | gltoolkit/src/main/java/com/quan404/gltoolkit/programs/ShaderProgram.java | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/ShaderHelper.java
// public class ShaderHelper {
// private static final String TAG = "ShaderHelper";
//
// public static int compileVertexShader(String code){
// return compileShader(GLES20.GL_VERTEX_SHADER, code);
// }
//
// public static int compileFragmentShader(String code){
// return compileShader(GLES20.GL_FRAGMENT_SHADER, code);
// }
//
// private static int compileShader(int type, String code){
// final int shaderObjectId = GLES20.glCreateShader(type);
//
// if (shaderObjectId == 0){
// if (LoggerConfig.ON){
// Log.w(TAG, "Could not create new shader");
// }
// return 0;
// }
//
// GLES20.glShaderSource(shaderObjectId, code);
// GLES20.glCompileShader(shaderObjectId);
//
// final int[] compileStatus = new int[1];
// GLES20.glGetShaderiv(shaderObjectId, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
//
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of compiling source: " + "\n" + code + "\n" + GLES20.glGetShaderInfoLog(shaderObjectId));
// }
//
// if (compileStatus[0] == 0){
// // if it failed, delete the shader object
// GLES20.glDeleteShader(shaderObjectId);
//
// if (LoggerConfig.ON){
// Log.w(TAG, "Compilation of shader failed");
// }
// return 0;
// }
// return shaderObjectId;
// }
//
// public static int linkProgram(int vertexShaderId, int fragmentShaderId){
// final int programObjectId = GLES20.glCreateProgram();
//
// if(programObjectId == 0){
// if (LoggerConfig.ON){
// Log.w(TAG, "Could not create new program");
// }
// return 0;
// }
//
// GLES20.glAttachShader(programObjectId, vertexShaderId);
// GLES20.glAttachShader(programObjectId, fragmentShaderId);
//
// GLES20.glLinkProgram(programObjectId);
//
// final int[] linkStatus = new int[1];
// GLES20.glGetProgramiv(programObjectId, GLES20.GL_LINK_STATUS, linkStatus, 0);
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of linking program: " + "\n" + GLES20.glGetProgramInfoLog(programObjectId));
// }
//
// if (linkStatus[0] == 0){
// // if it failed, delete the shader object
// GLES20.glDeleteProgram(programObjectId);
//
// if (LoggerConfig.ON){
// Log.w(TAG, "Linking of program failed");
// }
// return 0;
// }
// return programObjectId;
// }
//
// public static boolean validateProgram(int programObjectId) {
// GLES20.glValidateProgram(programObjectId);
//
// final int[] validateStatus = new int[1];
// GLES20.glGetProgramiv(programObjectId, GLES20.GL_VALIDATE_STATUS, validateStatus, 0);
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of validating program: " + validateStatus[0] + "\nLog: " + GLES20.glGetProgramInfoLog(programObjectId));
// }
// return validateStatus[0] != 0;
// }
//
// public static int buildProgram(String vertexShaderSource, String fragmentShaderSource){
// int program;
//
// // compile the shaders
// int vertexShader = compileVertexShader(vertexShaderSource);
// int fragmentShader = compileFragmentShader(fragmentShaderSource);
//
// // link them into a shader program
// program = linkProgram(vertexShader, fragmentShader);
//
// if (LoggerConfig.ON){
// validateProgram(program);
// }
//
// return program;
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/TextResourceReader.java
// public class TextResourceReader {
// public static String readTextFileFromResource(Context context, int resourceId) {
// StringBuilder body = new StringBuilder();
//
// try{
// InputStream inputStream = context.getResources().openRawResource(resourceId);
// InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
//
// BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
//
// String nextLine;
//
// while ((nextLine = bufferedReader.readLine()) != null){
// body.append(nextLine);
// body.append("\n");
// }
// }catch (IOException e){
// throw new RuntimeException("Could not open resource: " + resourceId, e);
// } catch (Resources.NotFoundException nfe){
// throw new RuntimeException("Resource not found: " + resourceId, nfe);
// }
//
// return body.toString();
// }
// }
| import android.content.Context;
import android.opengl.GLES20;
import android.util.Log;
import com.quan404.gltoolkit.ShaderHelper;
import com.quan404.gltoolkit.TextResourceReader; | package com.quan404.gltoolkit.programs;
/**
* Created by quanhua on 05/01/2016.
*/
abstract class ShaderProgram {
// Uniform constants
protected static final String U_MATRIX = "u_Matrix";
protected static final String U_TEXTURE_UNIT = "u_TextureUnit";
protected static final String U_COLOR = "u_Color";
protected static final String U_MVPMATRIX = "u_MVPMatrix";
protected static final String U_STMATRIX = "u_STMatrix";
// Attribute constants
protected static final String A_POSITION = "a_Position";
protected static final String A_COLOR = "a_Color";
protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
// Shader program
protected final int program;
protected ShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
program = ShaderHelper.buildProgram( | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/ShaderHelper.java
// public class ShaderHelper {
// private static final String TAG = "ShaderHelper";
//
// public static int compileVertexShader(String code){
// return compileShader(GLES20.GL_VERTEX_SHADER, code);
// }
//
// public static int compileFragmentShader(String code){
// return compileShader(GLES20.GL_FRAGMENT_SHADER, code);
// }
//
// private static int compileShader(int type, String code){
// final int shaderObjectId = GLES20.glCreateShader(type);
//
// if (shaderObjectId == 0){
// if (LoggerConfig.ON){
// Log.w(TAG, "Could not create new shader");
// }
// return 0;
// }
//
// GLES20.glShaderSource(shaderObjectId, code);
// GLES20.glCompileShader(shaderObjectId);
//
// final int[] compileStatus = new int[1];
// GLES20.glGetShaderiv(shaderObjectId, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
//
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of compiling source: " + "\n" + code + "\n" + GLES20.glGetShaderInfoLog(shaderObjectId));
// }
//
// if (compileStatus[0] == 0){
// // if it failed, delete the shader object
// GLES20.glDeleteShader(shaderObjectId);
//
// if (LoggerConfig.ON){
// Log.w(TAG, "Compilation of shader failed");
// }
// return 0;
// }
// return shaderObjectId;
// }
//
// public static int linkProgram(int vertexShaderId, int fragmentShaderId){
// final int programObjectId = GLES20.glCreateProgram();
//
// if(programObjectId == 0){
// if (LoggerConfig.ON){
// Log.w(TAG, "Could not create new program");
// }
// return 0;
// }
//
// GLES20.glAttachShader(programObjectId, vertexShaderId);
// GLES20.glAttachShader(programObjectId, fragmentShaderId);
//
// GLES20.glLinkProgram(programObjectId);
//
// final int[] linkStatus = new int[1];
// GLES20.glGetProgramiv(programObjectId, GLES20.GL_LINK_STATUS, linkStatus, 0);
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of linking program: " + "\n" + GLES20.glGetProgramInfoLog(programObjectId));
// }
//
// if (linkStatus[0] == 0){
// // if it failed, delete the shader object
// GLES20.glDeleteProgram(programObjectId);
//
// if (LoggerConfig.ON){
// Log.w(TAG, "Linking of program failed");
// }
// return 0;
// }
// return programObjectId;
// }
//
// public static boolean validateProgram(int programObjectId) {
// GLES20.glValidateProgram(programObjectId);
//
// final int[] validateStatus = new int[1];
// GLES20.glGetProgramiv(programObjectId, GLES20.GL_VALIDATE_STATUS, validateStatus, 0);
// if (LoggerConfig.ON){
// Log.v(TAG, "Results of validating program: " + validateStatus[0] + "\nLog: " + GLES20.glGetProgramInfoLog(programObjectId));
// }
// return validateStatus[0] != 0;
// }
//
// public static int buildProgram(String vertexShaderSource, String fragmentShaderSource){
// int program;
//
// // compile the shaders
// int vertexShader = compileVertexShader(vertexShaderSource);
// int fragmentShader = compileFragmentShader(fragmentShaderSource);
//
// // link them into a shader program
// program = linkProgram(vertexShader, fragmentShader);
//
// if (LoggerConfig.ON){
// validateProgram(program);
// }
//
// return program;
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/TextResourceReader.java
// public class TextResourceReader {
// public static String readTextFileFromResource(Context context, int resourceId) {
// StringBuilder body = new StringBuilder();
//
// try{
// InputStream inputStream = context.getResources().openRawResource(resourceId);
// InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
//
// BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
//
// String nextLine;
//
// while ((nextLine = bufferedReader.readLine()) != null){
// body.append(nextLine);
// body.append("\n");
// }
// }catch (IOException e){
// throw new RuntimeException("Could not open resource: " + resourceId, e);
// } catch (Resources.NotFoundException nfe){
// throw new RuntimeException("Resource not found: " + resourceId, nfe);
// }
//
// return body.toString();
// }
// }
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/programs/ShaderProgram.java
import android.content.Context;
import android.opengl.GLES20;
import android.util.Log;
import com.quan404.gltoolkit.ShaderHelper;
import com.quan404.gltoolkit.TextResourceReader;
package com.quan404.gltoolkit.programs;
/**
* Created by quanhua on 05/01/2016.
*/
abstract class ShaderProgram {
// Uniform constants
protected static final String U_MATRIX = "u_Matrix";
protected static final String U_TEXTURE_UNIT = "u_TextureUnit";
protected static final String U_COLOR = "u_Color";
protected static final String U_MVPMATRIX = "u_MVPMatrix";
protected static final String U_STMATRIX = "u_STMatrix";
// Attribute constants
protected static final String A_POSITION = "a_Position";
protected static final String A_COLOR = "a_Color";
protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
// Shader program
protected final int program;
protected ShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
program = ShaderHelper.buildProgram( | TextResourceReader.readTextFileFromResource(context, vertexShaderResourceId), |
quanhua92/GLMediaPlayer | gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java
// public class Constants {
// public static final int BYTES_PER_FLOAT = 4;
// }
| import android.opengl.GLES20;
import com.quan404.gltoolkit.Constants;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer; | package com.quan404.gltoolkit.data;
/**
* Created by quanhua on 05/01/2016.
*/
public class VertexArray {
private final FloatBuffer floatBuffer;
public VertexArray(float[] vertexData){ | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java
// public class Constants {
// public static final int BYTES_PER_FLOAT = 4;
// }
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java
import android.opengl.GLES20;
import com.quan404.gltoolkit.Constants;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
package com.quan404.gltoolkit.data;
/**
* Created by quanhua on 05/01/2016.
*/
public class VertexArray {
private final FloatBuffer floatBuffer;
public VertexArray(float[] vertexData){ | floatBuffer =ByteBuffer.allocateDirect(vertexData.length * Constants.BYTES_PER_FLOAT) |
quanhua92/GLMediaPlayer | 02_split_video_player/src/main/java/com/quan404/split_video_player/MainActivity.java | // Path: glmediaplayer/src/main/java/com/quan404/glmediaplayer/GLMediaPlayer.java
// public class GLMediaPlayer {
// private final static String TAG = "GLMediaPlayer";
// private BasePlayer mediaPlayer = null;
// private Context context = null;
// private VideoSurfaceView mVideoView;
//
// //=================== + Constructors + ===================
// public GLMediaPlayer(Context context) {
// this(context, false);
// }
// public GLMediaPlayer(Context context, boolean useExoPlayer) {
// this(context, new DefaultVideoRenderer(context), useExoPlayer);
// }
//
// public GLMediaPlayer(Context context, BaseVideoRenderer renderer, boolean useExoPlayer) {
// if(renderer == null) {
// if(LogConfig.ON){
// Log.e(TAG, "Renderer is null");
// }
// return;
// }
// if(useExoPlayer){
// this.mediaPlayer = new CustomExoPlayer(context);
// }else{
// this.mediaPlayer = new AndroidPlayer();
// }
//
// this.context = context;
// this.mVideoView = new VideoSurfaceView(context, renderer);
// renderer.setGlMediaPlayer(this);
// }
//
// //=================== + Getter + ===================
//
// public VideoSurfaceView getVideoSurfaceView(){
// return mVideoView;
// }
//
// //=================== + Setter + ===================
// public void setDataSource(String dataSource) {
// if (mediaPlayer != null){
// try {
// mediaPlayer.setDataSource(dataSource);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }else {
// if(LogConfig.ON){
// Log.e(TAG, "setDataSource: mediaPlayer == null");
// }
// }
// }
//
// public void pause(){
// if(LogConfig.ON){
// Log.d(TAG, "pause()");
// }
//
// if(mediaPlayer.isPlaying()){
// mediaPlayer.pause();
// }
// }
//
// public void resume(){
// if(LogConfig.ON){
// Log.d(TAG, "resume()");
// }
// // TODO: Resume player
//
// if(mVideoView != null){
// if( mVideoView.getRenderer().isReady()){
// if(mediaPlayer instanceof CustomExoPlayer) {
// CustomExoPlayer exoPlayer = (CustomExoPlayer) this.mediaPlayer;
// exoPlayer.resume();
// } else {
// this.mediaPlayer.start();
// }
// }
// }
// }
//
// public void setSurface(Surface surface) {
// this.mediaPlayer.setSurface(surface);
// }
//
// public void prepare() {
// try{
// this.mediaPlayer.prepare();
// }catch (Exception e){
// e.printStackTrace();
// }
// }
//
// public void start() {
// try{
// this.mediaPlayer.start();
// }catch (Exception e){
// e.printStackTrace();
// }
// }
// public void setOnVideoSizeChangedListener(BasePlayer.OnVideoSizeChangedListener listener){
// this.mediaPlayer.setOnVideoSizeChangedListener(listener);
// }
//
// public BasePlayer getMediaPlayer() {
// return mediaPlayer;
// }
// }
//
// Path: glmediaplayer/src/main/java/com/quan404/glmediaplayer/renderers/SplitVideoRenderer.java
// public class SplitVideoRenderer extends BaseVideoRenderer{
//
// private static final String TAG = "SplitVideoRenderer";
// private Video video_top;
// private Video video_bottom;
//
// public SplitVideoRenderer(Context context) {
// super(context);
// }
//
// @Override
// public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
// super.onSurfaceCreated(gl10, eglConfig);
//
// float[] VERTEX_DATA_TOP = {
// // X, Y, Z, U, V
// -1.0f, 0f, 0, 0.f, 0.f,
// 1.0f, 0f, 0, 0.5f, 0.f,
// -1.0f, 1.0f, 0, 0.f, 1.f,
// 1.0f, 1.0f, 0, 0.5f, 1.f,
// };
// video_top = new Video(VERTEX_DATA_TOP);
// float[] VERTEX_DATA_BOTTOM = {
// // X, Y, Z, U, V
// -1.0f, -1.0f, 0, 0.5f, 0.f,
// 1.0f, -1.0f, 0, 1f, 0.f,
// -1.0f, 0f, 0, 0.5f, 1.f,
// 1.0f, 0f, 0, 1f, 1.f,
// };
// video_bottom = new Video(VERTEX_DATA_BOTTOM);
// }
//
// @Override
// public void onDrawFrame(GL10 gl10) {
// super.onDrawFrame(gl10);
//
// video_top.bindData(videoShaderProgram);
// video_top.draw();
//
// video_bottom.bindData(videoShaderProgram);
// video_bottom.draw();
// }
// }
| import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.quan404.glmediaplayer.GLMediaPlayer;
import com.quan404.glmediaplayer.renderers.SplitVideoRenderer; | package com.quan404.split_video_player;
public class MainActivity extends AppCompatActivity {
private GLMediaPlayer glMediaPlayer = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| // Path: glmediaplayer/src/main/java/com/quan404/glmediaplayer/GLMediaPlayer.java
// public class GLMediaPlayer {
// private final static String TAG = "GLMediaPlayer";
// private BasePlayer mediaPlayer = null;
// private Context context = null;
// private VideoSurfaceView mVideoView;
//
// //=================== + Constructors + ===================
// public GLMediaPlayer(Context context) {
// this(context, false);
// }
// public GLMediaPlayer(Context context, boolean useExoPlayer) {
// this(context, new DefaultVideoRenderer(context), useExoPlayer);
// }
//
// public GLMediaPlayer(Context context, BaseVideoRenderer renderer, boolean useExoPlayer) {
// if(renderer == null) {
// if(LogConfig.ON){
// Log.e(TAG, "Renderer is null");
// }
// return;
// }
// if(useExoPlayer){
// this.mediaPlayer = new CustomExoPlayer(context);
// }else{
// this.mediaPlayer = new AndroidPlayer();
// }
//
// this.context = context;
// this.mVideoView = new VideoSurfaceView(context, renderer);
// renderer.setGlMediaPlayer(this);
// }
//
// //=================== + Getter + ===================
//
// public VideoSurfaceView getVideoSurfaceView(){
// return mVideoView;
// }
//
// //=================== + Setter + ===================
// public void setDataSource(String dataSource) {
// if (mediaPlayer != null){
// try {
// mediaPlayer.setDataSource(dataSource);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }else {
// if(LogConfig.ON){
// Log.e(TAG, "setDataSource: mediaPlayer == null");
// }
// }
// }
//
// public void pause(){
// if(LogConfig.ON){
// Log.d(TAG, "pause()");
// }
//
// if(mediaPlayer.isPlaying()){
// mediaPlayer.pause();
// }
// }
//
// public void resume(){
// if(LogConfig.ON){
// Log.d(TAG, "resume()");
// }
// // TODO: Resume player
//
// if(mVideoView != null){
// if( mVideoView.getRenderer().isReady()){
// if(mediaPlayer instanceof CustomExoPlayer) {
// CustomExoPlayer exoPlayer = (CustomExoPlayer) this.mediaPlayer;
// exoPlayer.resume();
// } else {
// this.mediaPlayer.start();
// }
// }
// }
// }
//
// public void setSurface(Surface surface) {
// this.mediaPlayer.setSurface(surface);
// }
//
// public void prepare() {
// try{
// this.mediaPlayer.prepare();
// }catch (Exception e){
// e.printStackTrace();
// }
// }
//
// public void start() {
// try{
// this.mediaPlayer.start();
// }catch (Exception e){
// e.printStackTrace();
// }
// }
// public void setOnVideoSizeChangedListener(BasePlayer.OnVideoSizeChangedListener listener){
// this.mediaPlayer.setOnVideoSizeChangedListener(listener);
// }
//
// public BasePlayer getMediaPlayer() {
// return mediaPlayer;
// }
// }
//
// Path: glmediaplayer/src/main/java/com/quan404/glmediaplayer/renderers/SplitVideoRenderer.java
// public class SplitVideoRenderer extends BaseVideoRenderer{
//
// private static final String TAG = "SplitVideoRenderer";
// private Video video_top;
// private Video video_bottom;
//
// public SplitVideoRenderer(Context context) {
// super(context);
// }
//
// @Override
// public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
// super.onSurfaceCreated(gl10, eglConfig);
//
// float[] VERTEX_DATA_TOP = {
// // X, Y, Z, U, V
// -1.0f, 0f, 0, 0.f, 0.f,
// 1.0f, 0f, 0, 0.5f, 0.f,
// -1.0f, 1.0f, 0, 0.f, 1.f,
// 1.0f, 1.0f, 0, 0.5f, 1.f,
// };
// video_top = new Video(VERTEX_DATA_TOP);
// float[] VERTEX_DATA_BOTTOM = {
// // X, Y, Z, U, V
// -1.0f, -1.0f, 0, 0.5f, 0.f,
// 1.0f, -1.0f, 0, 1f, 0.f,
// -1.0f, 0f, 0, 0.5f, 1.f,
// 1.0f, 0f, 0, 1f, 1.f,
// };
// video_bottom = new Video(VERTEX_DATA_BOTTOM);
// }
//
// @Override
// public void onDrawFrame(GL10 gl10) {
// super.onDrawFrame(gl10);
//
// video_top.bindData(videoShaderProgram);
// video_top.draw();
//
// video_bottom.bindData(videoShaderProgram);
// video_bottom.draw();
// }
// }
// Path: 02_split_video_player/src/main/java/com/quan404/split_video_player/MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.quan404.glmediaplayer.GLMediaPlayer;
import com.quan404.glmediaplayer.renderers.SplitVideoRenderer;
package com.quan404.split_video_player;
public class MainActivity extends AppCompatActivity {
private GLMediaPlayer glMediaPlayer = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| glMediaPlayer = new GLMediaPlayer(this, new SplitVideoRenderer(this), false); |
quanhua92/GLMediaPlayer | glmediaplayer/src/main/java/com/quan404/glmediaplayer/renderers/SplitSquareVideoRenderer.java | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java
// public class Video {
// private static final int POSITION_COMPONENT_COUNT = 3;
// private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2;
// private static final int STRIDE = (POSITION_COMPONENT_COUNT + TEXTURE_COORDINATES_COMPONENT_COUNT) * Constants.BYTES_PER_FLOAT;
//
// private VertexArray vertexArray;
//
// public Video(float[] vertex){
// this.vertexArray = new VertexArray(vertex);
// }
//
// public void bindData(VideoShaderProgram videoShaderProgram){
// vertexArray.setVertexAttribPointer(
// 0,
// videoShaderProgram.getPositionAttributeLocation(),
// POSITION_COMPONENT_COUNT,
// STRIDE
// );
//
// vertexArray.setVertexAttribPointer(
// POSITION_COMPONENT_COUNT,
// videoShaderProgram.getTextureCoordinatesAttributeLocation(),
// TEXTURE_COORDINATES_COMPONENT_COUNT,
// STRIDE
// );
// }
//
// public void draw(){
// GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
// }
//
// public void setVertexArray(float[] vertex){
// this.vertexArray = new VertexArray(vertex);
// }
// }
| import android.content.Context;
import android.media.MediaPlayer;
import android.util.Log;
import com.quan404.gltoolkit.objects.Video;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10; | package com.quan404.glmediaplayer.renderers;
/**
* Created by quanhua on 06/01/2016.
*/
public class SplitSquareVideoRenderer extends BaseVideoRenderer{
private static final String TAG = "SplitSquareRenderer"; | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java
// public class Video {
// private static final int POSITION_COMPONENT_COUNT = 3;
// private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2;
// private static final int STRIDE = (POSITION_COMPONENT_COUNT + TEXTURE_COORDINATES_COMPONENT_COUNT) * Constants.BYTES_PER_FLOAT;
//
// private VertexArray vertexArray;
//
// public Video(float[] vertex){
// this.vertexArray = new VertexArray(vertex);
// }
//
// public void bindData(VideoShaderProgram videoShaderProgram){
// vertexArray.setVertexAttribPointer(
// 0,
// videoShaderProgram.getPositionAttributeLocation(),
// POSITION_COMPONENT_COUNT,
// STRIDE
// );
//
// vertexArray.setVertexAttribPointer(
// POSITION_COMPONENT_COUNT,
// videoShaderProgram.getTextureCoordinatesAttributeLocation(),
// TEXTURE_COORDINATES_COMPONENT_COUNT,
// STRIDE
// );
// }
//
// public void draw(){
// GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
// }
//
// public void setVertexArray(float[] vertex){
// this.vertexArray = new VertexArray(vertex);
// }
// }
// Path: glmediaplayer/src/main/java/com/quan404/glmediaplayer/renderers/SplitSquareVideoRenderer.java
import android.content.Context;
import android.media.MediaPlayer;
import android.util.Log;
import com.quan404.gltoolkit.objects.Video;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
package com.quan404.glmediaplayer.renderers;
/**
* Created by quanhua on 06/01/2016.
*/
public class SplitSquareVideoRenderer extends BaseVideoRenderer{
private static final String TAG = "SplitSquareRenderer"; | private Video video_left; |
quanhua92/GLMediaPlayer | gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java
// public class Constants {
// public static final int BYTES_PER_FLOAT = 4;
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java
// public class VertexArray {
// private final FloatBuffer floatBuffer;
//
//
// public VertexArray(float[] vertexData){
// floatBuffer =ByteBuffer.allocateDirect(vertexData.length * Constants.BYTES_PER_FLOAT)
// .order(ByteOrder.nativeOrder())
// .asFloatBuffer()
// .put(vertexData);
// }
//
// public void setVertexAttribPointer( int dataOffset, int attributeLocation, int componentCount, int stride){
// floatBuffer.position(dataOffset);
// GLES20.glVertexAttribPointer(attributeLocation, componentCount, GLES20.GL_FLOAT, false, stride, floatBuffer);
// GLES20.glEnableVertexAttribArray(attributeLocation);
//
// floatBuffer.position(0);
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/programs/VideoShaderProgram.java
// public class VideoShaderProgram extends ShaderProgram {
//
// public static final int DEFAULT_VERTEX_SHADER = com.quan404.gltoolkit.R.raw.default_vertex_shader;
// public static final int DEFAULT_FRAGMENT_SHADER = com.quan404.gltoolkit.R.raw.default_fragment_shader;
//
// // Uniform locations
// private int uMVPMatrixLocation;
// private int uSTMatrixLocation;
//
// // Attribute locations
// private int aPositionLocation;
// private int aTextureCoordinatesLocation;
//
// public VideoShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
// super(context, vertexShaderResourceId, fragmentShaderResourceId);
//
// aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
// aTextureCoordinatesLocation = GLES20.glGetAttribLocation(program, A_TEXTURE_COORDINATES);
//
// uMVPMatrixLocation = GLES20.glGetUniformLocation(program, U_MVPMATRIX);
// uSTMatrixLocation = GLES20.glGetUniformLocation(program, U_STMATRIX);
// }
//
// public int getPositionAttributeLocation() {
// return aPositionLocation;
// }
//
// public int getTextureCoordinatesAttributeLocation() {
// return aTextureCoordinatesLocation;
// }
// public void setUniforms(float[] mvpMatrix, float[] stMatrix){
// GLES20.glUniformMatrix4fv(uMVPMatrixLocation, 1, false, mvpMatrix, 0 );
// GLES20.glUniformMatrix4fv(uSTMatrixLocation, 1, false, stMatrix, 0 );
// }
// }
| import android.opengl.GLES20;
import com.quan404.gltoolkit.Constants;
import com.quan404.gltoolkit.data.VertexArray;
import com.quan404.gltoolkit.programs.VideoShaderProgram;
import java.nio.FloatBuffer; | package com.quan404.gltoolkit.objects;
/**
* Created by quanhua on 06/01/2016.
*/
public class Video {
private static final int POSITION_COMPONENT_COUNT = 3;
private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2; | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java
// public class Constants {
// public static final int BYTES_PER_FLOAT = 4;
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java
// public class VertexArray {
// private final FloatBuffer floatBuffer;
//
//
// public VertexArray(float[] vertexData){
// floatBuffer =ByteBuffer.allocateDirect(vertexData.length * Constants.BYTES_PER_FLOAT)
// .order(ByteOrder.nativeOrder())
// .asFloatBuffer()
// .put(vertexData);
// }
//
// public void setVertexAttribPointer( int dataOffset, int attributeLocation, int componentCount, int stride){
// floatBuffer.position(dataOffset);
// GLES20.glVertexAttribPointer(attributeLocation, componentCount, GLES20.GL_FLOAT, false, stride, floatBuffer);
// GLES20.glEnableVertexAttribArray(attributeLocation);
//
// floatBuffer.position(0);
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/programs/VideoShaderProgram.java
// public class VideoShaderProgram extends ShaderProgram {
//
// public static final int DEFAULT_VERTEX_SHADER = com.quan404.gltoolkit.R.raw.default_vertex_shader;
// public static final int DEFAULT_FRAGMENT_SHADER = com.quan404.gltoolkit.R.raw.default_fragment_shader;
//
// // Uniform locations
// private int uMVPMatrixLocation;
// private int uSTMatrixLocation;
//
// // Attribute locations
// private int aPositionLocation;
// private int aTextureCoordinatesLocation;
//
// public VideoShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
// super(context, vertexShaderResourceId, fragmentShaderResourceId);
//
// aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
// aTextureCoordinatesLocation = GLES20.glGetAttribLocation(program, A_TEXTURE_COORDINATES);
//
// uMVPMatrixLocation = GLES20.glGetUniformLocation(program, U_MVPMATRIX);
// uSTMatrixLocation = GLES20.glGetUniformLocation(program, U_STMATRIX);
// }
//
// public int getPositionAttributeLocation() {
// return aPositionLocation;
// }
//
// public int getTextureCoordinatesAttributeLocation() {
// return aTextureCoordinatesLocation;
// }
// public void setUniforms(float[] mvpMatrix, float[] stMatrix){
// GLES20.glUniformMatrix4fv(uMVPMatrixLocation, 1, false, mvpMatrix, 0 );
// GLES20.glUniformMatrix4fv(uSTMatrixLocation, 1, false, stMatrix, 0 );
// }
// }
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java
import android.opengl.GLES20;
import com.quan404.gltoolkit.Constants;
import com.quan404.gltoolkit.data.VertexArray;
import com.quan404.gltoolkit.programs.VideoShaderProgram;
import java.nio.FloatBuffer;
package com.quan404.gltoolkit.objects;
/**
* Created by quanhua on 06/01/2016.
*/
public class Video {
private static final int POSITION_COMPONENT_COUNT = 3;
private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2; | private static final int STRIDE = (POSITION_COMPONENT_COUNT + TEXTURE_COORDINATES_COMPONENT_COUNT) * Constants.BYTES_PER_FLOAT; |
quanhua92/GLMediaPlayer | gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java
// public class Constants {
// public static final int BYTES_PER_FLOAT = 4;
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java
// public class VertexArray {
// private final FloatBuffer floatBuffer;
//
//
// public VertexArray(float[] vertexData){
// floatBuffer =ByteBuffer.allocateDirect(vertexData.length * Constants.BYTES_PER_FLOAT)
// .order(ByteOrder.nativeOrder())
// .asFloatBuffer()
// .put(vertexData);
// }
//
// public void setVertexAttribPointer( int dataOffset, int attributeLocation, int componentCount, int stride){
// floatBuffer.position(dataOffset);
// GLES20.glVertexAttribPointer(attributeLocation, componentCount, GLES20.GL_FLOAT, false, stride, floatBuffer);
// GLES20.glEnableVertexAttribArray(attributeLocation);
//
// floatBuffer.position(0);
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/programs/VideoShaderProgram.java
// public class VideoShaderProgram extends ShaderProgram {
//
// public static final int DEFAULT_VERTEX_SHADER = com.quan404.gltoolkit.R.raw.default_vertex_shader;
// public static final int DEFAULT_FRAGMENT_SHADER = com.quan404.gltoolkit.R.raw.default_fragment_shader;
//
// // Uniform locations
// private int uMVPMatrixLocation;
// private int uSTMatrixLocation;
//
// // Attribute locations
// private int aPositionLocation;
// private int aTextureCoordinatesLocation;
//
// public VideoShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
// super(context, vertexShaderResourceId, fragmentShaderResourceId);
//
// aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
// aTextureCoordinatesLocation = GLES20.glGetAttribLocation(program, A_TEXTURE_COORDINATES);
//
// uMVPMatrixLocation = GLES20.glGetUniformLocation(program, U_MVPMATRIX);
// uSTMatrixLocation = GLES20.glGetUniformLocation(program, U_STMATRIX);
// }
//
// public int getPositionAttributeLocation() {
// return aPositionLocation;
// }
//
// public int getTextureCoordinatesAttributeLocation() {
// return aTextureCoordinatesLocation;
// }
// public void setUniforms(float[] mvpMatrix, float[] stMatrix){
// GLES20.glUniformMatrix4fv(uMVPMatrixLocation, 1, false, mvpMatrix, 0 );
// GLES20.glUniformMatrix4fv(uSTMatrixLocation, 1, false, stMatrix, 0 );
// }
// }
| import android.opengl.GLES20;
import com.quan404.gltoolkit.Constants;
import com.quan404.gltoolkit.data.VertexArray;
import com.quan404.gltoolkit.programs.VideoShaderProgram;
import java.nio.FloatBuffer; | package com.quan404.gltoolkit.objects;
/**
* Created by quanhua on 06/01/2016.
*/
public class Video {
private static final int POSITION_COMPONENT_COUNT = 3;
private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2;
private static final int STRIDE = (POSITION_COMPONENT_COUNT + TEXTURE_COORDINATES_COMPONENT_COUNT) * Constants.BYTES_PER_FLOAT;
| // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java
// public class Constants {
// public static final int BYTES_PER_FLOAT = 4;
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java
// public class VertexArray {
// private final FloatBuffer floatBuffer;
//
//
// public VertexArray(float[] vertexData){
// floatBuffer =ByteBuffer.allocateDirect(vertexData.length * Constants.BYTES_PER_FLOAT)
// .order(ByteOrder.nativeOrder())
// .asFloatBuffer()
// .put(vertexData);
// }
//
// public void setVertexAttribPointer( int dataOffset, int attributeLocation, int componentCount, int stride){
// floatBuffer.position(dataOffset);
// GLES20.glVertexAttribPointer(attributeLocation, componentCount, GLES20.GL_FLOAT, false, stride, floatBuffer);
// GLES20.glEnableVertexAttribArray(attributeLocation);
//
// floatBuffer.position(0);
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/programs/VideoShaderProgram.java
// public class VideoShaderProgram extends ShaderProgram {
//
// public static final int DEFAULT_VERTEX_SHADER = com.quan404.gltoolkit.R.raw.default_vertex_shader;
// public static final int DEFAULT_FRAGMENT_SHADER = com.quan404.gltoolkit.R.raw.default_fragment_shader;
//
// // Uniform locations
// private int uMVPMatrixLocation;
// private int uSTMatrixLocation;
//
// // Attribute locations
// private int aPositionLocation;
// private int aTextureCoordinatesLocation;
//
// public VideoShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
// super(context, vertexShaderResourceId, fragmentShaderResourceId);
//
// aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
// aTextureCoordinatesLocation = GLES20.glGetAttribLocation(program, A_TEXTURE_COORDINATES);
//
// uMVPMatrixLocation = GLES20.glGetUniformLocation(program, U_MVPMATRIX);
// uSTMatrixLocation = GLES20.glGetUniformLocation(program, U_STMATRIX);
// }
//
// public int getPositionAttributeLocation() {
// return aPositionLocation;
// }
//
// public int getTextureCoordinatesAttributeLocation() {
// return aTextureCoordinatesLocation;
// }
// public void setUniforms(float[] mvpMatrix, float[] stMatrix){
// GLES20.glUniformMatrix4fv(uMVPMatrixLocation, 1, false, mvpMatrix, 0 );
// GLES20.glUniformMatrix4fv(uSTMatrixLocation, 1, false, stMatrix, 0 );
// }
// }
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java
import android.opengl.GLES20;
import com.quan404.gltoolkit.Constants;
import com.quan404.gltoolkit.data.VertexArray;
import com.quan404.gltoolkit.programs.VideoShaderProgram;
import java.nio.FloatBuffer;
package com.quan404.gltoolkit.objects;
/**
* Created by quanhua on 06/01/2016.
*/
public class Video {
private static final int POSITION_COMPONENT_COUNT = 3;
private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2;
private static final int STRIDE = (POSITION_COMPONENT_COUNT + TEXTURE_COORDINATES_COMPONENT_COUNT) * Constants.BYTES_PER_FLOAT;
| private VertexArray vertexArray; |
quanhua92/GLMediaPlayer | gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java | // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java
// public class Constants {
// public static final int BYTES_PER_FLOAT = 4;
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java
// public class VertexArray {
// private final FloatBuffer floatBuffer;
//
//
// public VertexArray(float[] vertexData){
// floatBuffer =ByteBuffer.allocateDirect(vertexData.length * Constants.BYTES_PER_FLOAT)
// .order(ByteOrder.nativeOrder())
// .asFloatBuffer()
// .put(vertexData);
// }
//
// public void setVertexAttribPointer( int dataOffset, int attributeLocation, int componentCount, int stride){
// floatBuffer.position(dataOffset);
// GLES20.glVertexAttribPointer(attributeLocation, componentCount, GLES20.GL_FLOAT, false, stride, floatBuffer);
// GLES20.glEnableVertexAttribArray(attributeLocation);
//
// floatBuffer.position(0);
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/programs/VideoShaderProgram.java
// public class VideoShaderProgram extends ShaderProgram {
//
// public static final int DEFAULT_VERTEX_SHADER = com.quan404.gltoolkit.R.raw.default_vertex_shader;
// public static final int DEFAULT_FRAGMENT_SHADER = com.quan404.gltoolkit.R.raw.default_fragment_shader;
//
// // Uniform locations
// private int uMVPMatrixLocation;
// private int uSTMatrixLocation;
//
// // Attribute locations
// private int aPositionLocation;
// private int aTextureCoordinatesLocation;
//
// public VideoShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
// super(context, vertexShaderResourceId, fragmentShaderResourceId);
//
// aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
// aTextureCoordinatesLocation = GLES20.glGetAttribLocation(program, A_TEXTURE_COORDINATES);
//
// uMVPMatrixLocation = GLES20.glGetUniformLocation(program, U_MVPMATRIX);
// uSTMatrixLocation = GLES20.glGetUniformLocation(program, U_STMATRIX);
// }
//
// public int getPositionAttributeLocation() {
// return aPositionLocation;
// }
//
// public int getTextureCoordinatesAttributeLocation() {
// return aTextureCoordinatesLocation;
// }
// public void setUniforms(float[] mvpMatrix, float[] stMatrix){
// GLES20.glUniformMatrix4fv(uMVPMatrixLocation, 1, false, mvpMatrix, 0 );
// GLES20.glUniformMatrix4fv(uSTMatrixLocation, 1, false, stMatrix, 0 );
// }
// }
| import android.opengl.GLES20;
import com.quan404.gltoolkit.Constants;
import com.quan404.gltoolkit.data.VertexArray;
import com.quan404.gltoolkit.programs.VideoShaderProgram;
import java.nio.FloatBuffer; | package com.quan404.gltoolkit.objects;
/**
* Created by quanhua on 06/01/2016.
*/
public class Video {
private static final int POSITION_COMPONENT_COUNT = 3;
private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2;
private static final int STRIDE = (POSITION_COMPONENT_COUNT + TEXTURE_COORDINATES_COMPONENT_COUNT) * Constants.BYTES_PER_FLOAT;
private VertexArray vertexArray;
public Video(float[] vertex){
this.vertexArray = new VertexArray(vertex);
}
| // Path: gltoolkit/src/main/java/com/quan404/gltoolkit/Constants.java
// public class Constants {
// public static final int BYTES_PER_FLOAT = 4;
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/data/VertexArray.java
// public class VertexArray {
// private final FloatBuffer floatBuffer;
//
//
// public VertexArray(float[] vertexData){
// floatBuffer =ByteBuffer.allocateDirect(vertexData.length * Constants.BYTES_PER_FLOAT)
// .order(ByteOrder.nativeOrder())
// .asFloatBuffer()
// .put(vertexData);
// }
//
// public void setVertexAttribPointer( int dataOffset, int attributeLocation, int componentCount, int stride){
// floatBuffer.position(dataOffset);
// GLES20.glVertexAttribPointer(attributeLocation, componentCount, GLES20.GL_FLOAT, false, stride, floatBuffer);
// GLES20.glEnableVertexAttribArray(attributeLocation);
//
// floatBuffer.position(0);
// }
// }
//
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/programs/VideoShaderProgram.java
// public class VideoShaderProgram extends ShaderProgram {
//
// public static final int DEFAULT_VERTEX_SHADER = com.quan404.gltoolkit.R.raw.default_vertex_shader;
// public static final int DEFAULT_FRAGMENT_SHADER = com.quan404.gltoolkit.R.raw.default_fragment_shader;
//
// // Uniform locations
// private int uMVPMatrixLocation;
// private int uSTMatrixLocation;
//
// // Attribute locations
// private int aPositionLocation;
// private int aTextureCoordinatesLocation;
//
// public VideoShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId) {
// super(context, vertexShaderResourceId, fragmentShaderResourceId);
//
// aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
// aTextureCoordinatesLocation = GLES20.glGetAttribLocation(program, A_TEXTURE_COORDINATES);
//
// uMVPMatrixLocation = GLES20.glGetUniformLocation(program, U_MVPMATRIX);
// uSTMatrixLocation = GLES20.glGetUniformLocation(program, U_STMATRIX);
// }
//
// public int getPositionAttributeLocation() {
// return aPositionLocation;
// }
//
// public int getTextureCoordinatesAttributeLocation() {
// return aTextureCoordinatesLocation;
// }
// public void setUniforms(float[] mvpMatrix, float[] stMatrix){
// GLES20.glUniformMatrix4fv(uMVPMatrixLocation, 1, false, mvpMatrix, 0 );
// GLES20.glUniformMatrix4fv(uSTMatrixLocation, 1, false, stMatrix, 0 );
// }
// }
// Path: gltoolkit/src/main/java/com/quan404/gltoolkit/objects/Video.java
import android.opengl.GLES20;
import com.quan404.gltoolkit.Constants;
import com.quan404.gltoolkit.data.VertexArray;
import com.quan404.gltoolkit.programs.VideoShaderProgram;
import java.nio.FloatBuffer;
package com.quan404.gltoolkit.objects;
/**
* Created by quanhua on 06/01/2016.
*/
public class Video {
private static final int POSITION_COMPONENT_COUNT = 3;
private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2;
private static final int STRIDE = (POSITION_COMPONENT_COUNT + TEXTURE_COORDINATES_COMPONENT_COUNT) * Constants.BYTES_PER_FLOAT;
private VertexArray vertexArray;
public Video(float[] vertex){
this.vertexArray = new VertexArray(vertex);
}
| public void bindData(VideoShaderProgram videoShaderProgram){ |
arquillian/arquillian-recorder | arquillian-recorder-video-base/arquillian-recorder-video-spi/src/main/java/org/arquillian/extension/recorder/video/event/StartRecordClassVideo.java | // Path: arquillian-recorder-video-base/arquillian-recorder-video-api/src/main/java/org/arquillian/extension/recorder/video/VideoType.java
// public enum VideoType implements ResourceType {
//
// MP4("mp4");
//
// private String name;
//
// VideoType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// /**
// *
// * @return all video types concatenated to one string separated only by one space from each other
// */
// public static String getAll() {
// StringBuilder sb = new StringBuilder();
//
// for (VideoType videoType : VideoType.values()) {
// sb.append(videoType.toString());
// sb.append(" ");
// }
//
// return sb.toString().trim();
// }
// }
| import org.arquillian.extension.recorder.video.VideoMetaData;
import org.arquillian.extension.recorder.video.VideoType; | /*
* JBoss, Home of Professional Open Source
* Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.event;
/**
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
public class StartRecordClassVideo {
private final VideoMetaData videoMetaData; | // Path: arquillian-recorder-video-base/arquillian-recorder-video-api/src/main/java/org/arquillian/extension/recorder/video/VideoType.java
// public enum VideoType implements ResourceType {
//
// MP4("mp4");
//
// private String name;
//
// VideoType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// /**
// *
// * @return all video types concatenated to one string separated only by one space from each other
// */
// public static String getAll() {
// StringBuilder sb = new StringBuilder();
//
// for (VideoType videoType : VideoType.values()) {
// sb.append(videoType.toString());
// sb.append(" ");
// }
//
// return sb.toString().trim();
// }
// }
// Path: arquillian-recorder-video-base/arquillian-recorder-video-spi/src/main/java/org/arquillian/extension/recorder/video/event/StartRecordClassVideo.java
import org.arquillian.extension.recorder.video.VideoMetaData;
import org.arquillian.extension.recorder.video.VideoType;
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.event;
/**
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
public class StartRecordClassVideo {
private final VideoMetaData videoMetaData; | private final VideoType videoType; |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/ScreenshotEntry.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
| import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.extension.recorder.When; | /*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents a screenshot being taken during some test.<br>
* <br>
* Can hold:
* <ul>
* <li>phase as {@link When}</li>
* <li>width</li>
* <li>height</li>
* <li>link</li>
* </ul>
*
* @see FileEntry
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "screenshot")
@XmlType(propOrder = { "phase", "width", "height", "link" })
public class ScreenshotEntry extends FileEntry {
| // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/ScreenshotEntry.java
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.extension.recorder.When;
/*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents a screenshot being taken during some test.<br>
* <br>
* Can hold:
* <ul>
* <li>phase as {@link When}</li>
* <li>width</li>
* <li>height</li>
* <li>link</li>
* </ul>
*
* @see FileEntry
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "screenshot")
@XmlType(propOrder = { "phase", "width", "height", "link" })
public class ScreenshotEntry extends FileEntry {
| private When phase; |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/ReportConfiguration.java | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/ReportEntry.java
// public interface ReportEntry extends Reportable {
//
// List<PropertyEntry> getPropertyEntries();
// }
| import java.util.List;
import java.util.logging.Logger;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.ReportEntry; |
public void setImageHeight(String imageHeight) {
try {
int parsedInt = Integer.parseInt(imageHeight);
if (parsedInt > 0 && parsedInt <= MAX_HEIGHT_IN_PERCENT) {
this.imageHeight = imageHeight;
}
} catch (NumberFormatException ex) {
LOGGER.info(String.format("You are trying to parse '%s' as a number for imageHeight.", imageHeight));
}
}
@XmlElement
public String getTitle() {
return title;
}
/**
* Title has to be non-null and non-empty string.
*
* @param title title of the whole Arquillian report
*/
public void setTitle(String title) {
if (title == null || title.isEmpty()) {
return;
}
this.title = title;
}
@Override | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/ReportEntry.java
// public interface ReportEntry extends Reportable {
//
// List<PropertyEntry> getPropertyEntries();
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/ReportConfiguration.java
import java.util.List;
import java.util.logging.Logger;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.ReportEntry;
public void setImageHeight(String imageHeight) {
try {
int parsedInt = Integer.parseInt(imageHeight);
if (parsedInt > 0 && parsedInt <= MAX_HEIGHT_IN_PERCENT) {
this.imageHeight = imageHeight;
}
} catch (NumberFormatException ex) {
LOGGER.info(String.format("You are trying to parse '%s' as a number for imageHeight.", imageHeight));
}
}
@XmlElement
public String getTitle() {
return title;
}
/**
* Title has to be non-null and non-empty string.
*
* @param title title of the whole Arquillian report
*/
public void setTitle(String title) {
if (title == null || title.isEmpty()) {
return;
}
this.title = title;
}
@Override | public List<PropertyEntry> getPropertyEntries() { |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-impl/src/main/java/org/arquillian/recorder/reporter/exporter/DefaultExporterRegisterFactory.java | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/ExporterRegister.java
// public interface ExporterRegister {
//
// ExporterRegister add(Exporter reporter);
//
// Exporter get(Class<? extends ReportType> reportType);
//
// void clear();
//
// List<Exporter> getAll();
//
// boolean isSupported(Class<? extends ReportType> reportType);
//
// }
| import org.arquillian.recorder.reporter.ExporterRegister;
import org.arquillian.recorder.reporter.ExporterRegisterFactory; | /*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.exporter;
/**
* Returns {@link ExporterRegister} as a singleton.
*
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class DefaultExporterRegisterFactory implements ExporterRegisterFactory {
private static class ExporterRegisterHolder { | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/ExporterRegister.java
// public interface ExporterRegister {
//
// ExporterRegister add(Exporter reporter);
//
// Exporter get(Class<? extends ReportType> reportType);
//
// void clear();
//
// List<Exporter> getAll();
//
// boolean isSupported(Class<? extends ReportType> reportType);
//
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-impl/src/main/java/org/arquillian/recorder/reporter/exporter/DefaultExporterRegisterFactory.java
import org.arquillian.recorder.reporter.ExporterRegister;
import org.arquillian.recorder.reporter.ExporterRegisterFactory;
/*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.exporter;
/**
* Returns {@link ExporterRegister} as a singleton.
*
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class DefaultExporterRegisterFactory implements ExporterRegisterFactory {
private static class ExporterRegisterHolder { | public static ExporterRegister lastRegister = new ExporterRegisterImpl(); |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/KeyValueEntry.java | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
| import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.recorder.reporter.PropertyEntry; | /*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents arbitrary key-value property element.<br>
* <br>
* Must hold:
* <ul>
* <li>key</li>
* <li>value</li>
* </ul>
*
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "property")
@XmlType(propOrder = { "key", "value" }) | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/KeyValueEntry.java
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.recorder.reporter.PropertyEntry;
/*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents arbitrary key-value property element.<br>
* <br>
* Must hold:
* <ul>
* <li>key</li>
* <li>value</li>
* </ul>
*
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "property")
@XmlType(propOrder = { "key", "value" }) | public class KeyValueEntry extends PropertyEntry { |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/table/TableEntry.java | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
| import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.recorder.reporter.PropertyEntry; | /*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry.table;
/**
* Entry which models table as a property, with header, rows and cells.
*
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "table")
@XmlType(propOrder = { "tableName", "tableHead", "tableBody", "tableFoot" }) | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/table/TableEntry.java
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.recorder.reporter.PropertyEntry;
/*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry.table;
/**
* Entry which models table as a property, with header, rows and cells.
*
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "table")
@XmlType(propOrder = { "tableName", "tableHead", "tableBody", "tableFoot" }) | public class TableEntry extends PropertyEntry { |
arquillian/arquillian-recorder | arquillian-recorder-video-base/arquillian-recorder-video-spi/src/main/java/org/arquillian/extension/recorder/video/event/StopRecordVideo.java | // Path: arquillian-recorder-video-base/arquillian-recorder-video-api/src/main/java/org/arquillian/extension/recorder/video/VideoType.java
// public enum VideoType implements ResourceType {
//
// MP4("mp4");
//
// private String name;
//
// VideoType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// /**
// *
// * @return all video types concatenated to one string separated only by one space from each other
// */
// public static String getAll() {
// StringBuilder sb = new StringBuilder();
//
// for (VideoType videoType : VideoType.values()) {
// sb.append(videoType.toString());
// sb.append(" ");
// }
//
// return sb.toString().trim();
// }
// }
| import org.arquillian.extension.recorder.video.VideoMetaData;
import org.arquillian.extension.recorder.video.VideoType; | /*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.event;
/**
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
public class StopRecordVideo {
private final VideoMetaData videoMetaData; | // Path: arquillian-recorder-video-base/arquillian-recorder-video-api/src/main/java/org/arquillian/extension/recorder/video/VideoType.java
// public enum VideoType implements ResourceType {
//
// MP4("mp4");
//
// private String name;
//
// VideoType(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// /**
// *
// * @return all video types concatenated to one string separated only by one space from each other
// */
// public static String getAll() {
// StringBuilder sb = new StringBuilder();
//
// for (VideoType videoType : VideoType.values()) {
// sb.append(videoType.toString());
// sb.append(" ");
// }
//
// return sb.toString().trim();
// }
// }
// Path: arquillian-recorder-video-base/arquillian-recorder-video-spi/src/main/java/org/arquillian/extension/recorder/video/event/StopRecordVideo.java
import org.arquillian.extension.recorder.video.VideoMetaData;
import org.arquillian.extension.recorder.video.VideoType;
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.event;
/**
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
public class StopRecordVideo {
private final VideoMetaData videoMetaData; | private final VideoType videoType; |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/VideoEntry.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
| import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.extension.recorder.When; | /*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents video being taken during test.<br>
* <br>
* Can hold:
* <ul>
* <li>phase as {@link When}</li>
* <li>width</li>
* <li>height</li>
* <li>link</li>
* </ul>
*
* @see FileEntry
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "video")
@XmlType(propOrder = { "phase", "width", "height", "link" })
public class VideoEntry extends FileEntry {
| // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/VideoEntry.java
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.extension.recorder.When;
/*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents video being taken during test.<br>
* <br>
* Can hold:
* <ul>
* <li>phase as {@link When}</li>
* <li>width</li>
* <li>height</li>
* <li>link</li>
* </ul>
*
* @see FileEntry
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "video")
@XmlType(propOrder = { "phase", "width", "height", "link" })
public class VideoEntry extends FileEntry {
| private When phase; |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/GroupEntry.java | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/table/TableEntry.java
// @XmlRootElement(name = "table")
// @XmlType(propOrder = { "tableName", "tableHead", "tableBody", "tableFoot" })
// public class TableEntry extends PropertyEntry {
//
// private final TableHeadEntry tableHead = new TableHeadEntry();
//
// private final TableBodyEntry tableBody = new TableBodyEntry();
//
// private final TableFootEntry tableFoot = new TableFootEntry();
//
// private String tableName;
//
// @XmlElement(name = "tbody", required = true)
// public TableBodyEntry getTableBody() {
// return tableBody;
// }
//
// @XmlElement(name = "thead")
// public TableHeadEntry getTableHead() {
// return tableHead;
// }
//
// @XmlElement(name = "tfoot")
// public TableFootEntry getTableFoot() {
// return tableFoot;
// }
//
// @XmlAttribute(name = "tableName")
// public String getTableName() {
// return tableName;
// }
//
// public void setTableName(String tableName) {
// this.tableName = tableName;
// }
//
// public int getNumberOfColumns() {
//
// int n = 0;
//
// for (TableRowEntry row : tableBody.getRows()) {
// int i = row.getTotalColspan();
// if (i > n) {
// n = i;
// }
// }
//
// return n;
// }
//
// public int getNumberOfRows() {
// return tableBody.getRows().size();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// if (!super.equals(o)) return false;
//
// TableEntry that = (TableEntry) o;
//
// if (!tableHead.equals(that.tableHead)) return false;
// if (!tableBody.equals(that.tableBody)) return false;
// if (!tableFoot.equals(that.tableFoot)) return false;
// return tableName != null ? tableName.equals(that.tableName) : that.tableName == null;
//
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + tableHead.hashCode();
// result = 31 * result + tableBody.hashCode();
// result = 31 * result + tableFoot.hashCode();
// result = 31 * result + (tableName != null ? tableName.hashCode() : 0);
// return result;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.model.entry.table.TableEntry; | /*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents group entry which can hold:<br>
* <br>
* <ul>
* <li>{@link KeyValueEntry}</li>
* <li>{@link TableEntry}</li>
* <li>{@link GroupEntry}</li>
* </ul>
*
* By providing the possibility to put {@link GroupEntry} into properties, we are introducing recursive reporting.
*
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "groupEntry")
public class GroupEntry extends PropertyEntry {
private String name;
@XmlElements({
@XmlElement(name = "property", type = KeyValueEntry.class),
@XmlElement(name = "text", type = TextEntry.class), | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/table/TableEntry.java
// @XmlRootElement(name = "table")
// @XmlType(propOrder = { "tableName", "tableHead", "tableBody", "tableFoot" })
// public class TableEntry extends PropertyEntry {
//
// private final TableHeadEntry tableHead = new TableHeadEntry();
//
// private final TableBodyEntry tableBody = new TableBodyEntry();
//
// private final TableFootEntry tableFoot = new TableFootEntry();
//
// private String tableName;
//
// @XmlElement(name = "tbody", required = true)
// public TableBodyEntry getTableBody() {
// return tableBody;
// }
//
// @XmlElement(name = "thead")
// public TableHeadEntry getTableHead() {
// return tableHead;
// }
//
// @XmlElement(name = "tfoot")
// public TableFootEntry getTableFoot() {
// return tableFoot;
// }
//
// @XmlAttribute(name = "tableName")
// public String getTableName() {
// return tableName;
// }
//
// public void setTableName(String tableName) {
// this.tableName = tableName;
// }
//
// public int getNumberOfColumns() {
//
// int n = 0;
//
// for (TableRowEntry row : tableBody.getRows()) {
// int i = row.getTotalColspan();
// if (i > n) {
// n = i;
// }
// }
//
// return n;
// }
//
// public int getNumberOfRows() {
// return tableBody.getRows().size();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// if (!super.equals(o)) return false;
//
// TableEntry that = (TableEntry) o;
//
// if (!tableHead.equals(that.tableHead)) return false;
// if (!tableBody.equals(that.tableBody)) return false;
// if (!tableFoot.equals(that.tableFoot)) return false;
// return tableName != null ? tableName.equals(that.tableName) : that.tableName == null;
//
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + tableHead.hashCode();
// result = 31 * result + tableBody.hashCode();
// result = 31 * result + tableFoot.hashCode();
// result = 31 * result + (tableName != null ? tableName.hashCode() : 0);
// return result;
// }
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/GroupEntry.java
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.model.entry.table.TableEntry;
/*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents group entry which can hold:<br>
* <br>
* <ul>
* <li>{@link KeyValueEntry}</li>
* <li>{@link TableEntry}</li>
* <li>{@link GroupEntry}</li>
* </ul>
*
* By providing the possibility to put {@link GroupEntry} into properties, we are introducing recursive reporting.
*
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "groupEntry")
public class GroupEntry extends PropertyEntry {
private String name;
@XmlElements({
@XmlElement(name = "property", type = KeyValueEntry.class),
@XmlElement(name = "text", type = TextEntry.class), | @XmlElement(name = "table", type = TableEntry.class), |
arquillian/arquillian-recorder | arquillian-recorder-video-base/arquillian-recorder-video-impl-base/src/main/java/org/arquillian/extension/recorder/video/impl/InTestVideoResourceReportObserver.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
| import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.video.Video;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes; | /**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestVideoResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
// Path: arquillian-recorder-video-base/arquillian-recorder-video-impl-base/src/main/java/org/arquillian/extension/recorder/video/impl/InTestVideoResourceReportObserver.java
import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.video.Video;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
/**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestVideoResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject | private Event<PropertyReportEvent> reportEvent; |
arquillian/arquillian-recorder | arquillian-recorder-video-base/arquillian-recorder-video-impl-base/src/main/java/org/arquillian/extension/recorder/video/impl/InTestVideoResourceReportObserver.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
| import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.video.Video;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes; | /**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestVideoResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
| // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
// Path: arquillian-recorder-video-base/arquillian-recorder-video-impl-base/src/main/java/org/arquillian/extension/recorder/video/impl/InTestVideoResourceReportObserver.java
import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.video.Video;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
/**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestVideoResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
| public void onInTestResourceReport(@Observes InTestResourceReport event) { |
arquillian/arquillian-recorder | arquillian-recorder-video-base/arquillian-recorder-video-impl-base/src/main/java/org/arquillian/extension/recorder/video/impl/InTestVideoResourceReportObserver.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
| import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.video.Video;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes; | /**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestVideoResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
public void onInTestResourceReport(@Observes InTestResourceReport event) {
TakenResourceRegister register = takenResourceRegister.get();
if (register == null) {
return; // no video implementation on the class path
}
for (Video video : register.getTakenVideos()) {
if (!register.getReportedVideos().contains(video)) {
| // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
// Path: arquillian-recorder-video-base/arquillian-recorder-video-impl-base/src/main/java/org/arquillian/extension/recorder/video/impl/InTestVideoResourceReportObserver.java
import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.video.Video;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
/**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestVideoResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
public void onInTestResourceReport(@Observes InTestResourceReport event) {
TakenResourceRegister register = takenResourceRegister.get();
if (register == null) {
return; // no video implementation on the class path
}
for (Video video : register.getTakenVideos()) {
if (!register.getReportedVideos().contains(video)) {
| PropertyEntry propertyEntry = new VideoReportEntryBuilder() |
arquillian/arquillian-recorder | arquillian-recorder-video-base/arquillian-recorder-video-impl-base/src/main/java/org/arquillian/extension/recorder/video/impl/InTestVideoResourceReportObserver.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
| import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.video.Video;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes; | /**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestVideoResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
public void onInTestResourceReport(@Observes InTestResourceReport event) {
TakenResourceRegister register = takenResourceRegister.get();
if (register == null) {
return; // no video implementation on the class path
}
for (Video video : register.getTakenVideos()) {
if (!register.getReportedVideos().contains(video)) {
PropertyEntry propertyEntry = new VideoReportEntryBuilder() | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
// Path: arquillian-recorder-video-base/arquillian-recorder-video-impl-base/src/main/java/org/arquillian/extension/recorder/video/impl/InTestVideoResourceReportObserver.java
import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.video.Video;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
/**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.video.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestVideoResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
public void onInTestResourceReport(@Observes InTestResourceReport event) {
TakenResourceRegister register = takenResourceRegister.get();
if (register == null) {
return; // no video implementation on the class path
}
for (Video video : register.getTakenVideos()) {
if (!register.getReportedVideos().contains(video)) {
PropertyEntry propertyEntry = new VideoReportEntryBuilder() | .withWhen(When.IN_TEST) |
arquillian/arquillian-recorder | arquillian-recorder-screenshooter-base/arquillian-recorder-screenshooter-impl-base/src/main/java/org/arquillian/extension/recorder/screenshooter/impl/InTestScreenshotResourceReportObserver.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
| import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.screenshooter.Screenshot;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes; | /**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.screenshooter.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestScreenshotResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
// Path: arquillian-recorder-screenshooter-base/arquillian-recorder-screenshooter-impl-base/src/main/java/org/arquillian/extension/recorder/screenshooter/impl/InTestScreenshotResourceReportObserver.java
import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.screenshooter.Screenshot;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
/**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.screenshooter.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestScreenshotResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject | private Event<PropertyReportEvent> reportEvent; |
arquillian/arquillian-recorder | arquillian-recorder-screenshooter-base/arquillian-recorder-screenshooter-impl-base/src/main/java/org/arquillian/extension/recorder/screenshooter/impl/InTestScreenshotResourceReportObserver.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
| import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.screenshooter.Screenshot;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes; | /**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.screenshooter.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestScreenshotResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
| // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
// Path: arquillian-recorder-screenshooter-base/arquillian-recorder-screenshooter-impl-base/src/main/java/org/arquillian/extension/recorder/screenshooter/impl/InTestScreenshotResourceReportObserver.java
import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.screenshooter.Screenshot;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
/**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.screenshooter.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestScreenshotResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
| public void onInTestResourceReport(@Observes InTestResourceReport event) { |
arquillian/arquillian-recorder | arquillian-recorder-screenshooter-base/arquillian-recorder-screenshooter-impl-base/src/main/java/org/arquillian/extension/recorder/screenshooter/impl/InTestScreenshotResourceReportObserver.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
| import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.screenshooter.Screenshot;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes; | /**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.screenshooter.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestScreenshotResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
public void onInTestResourceReport(@Observes InTestResourceReport event) {
TakenResourceRegister register = takenResourceRegister.get();
for (Screenshot screenshot : register.getTakenScreenshots()) {
if (!register.getReportedScreenshots().contains(screenshot)) {
| // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
// Path: arquillian-recorder-screenshooter-base/arquillian-recorder-screenshooter-impl-base/src/main/java/org/arquillian/extension/recorder/screenshooter/impl/InTestScreenshotResourceReportObserver.java
import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.screenshooter.Screenshot;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
/**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.screenshooter.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestScreenshotResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
public void onInTestResourceReport(@Observes InTestResourceReport event) {
TakenResourceRegister register = takenResourceRegister.get();
for (Screenshot screenshot : register.getTakenScreenshots()) {
if (!register.getReportedScreenshots().contains(screenshot)) {
| PropertyEntry propertyEntry = new ScreenshotReportEntryBuilder() |
arquillian/arquillian-recorder | arquillian-recorder-screenshooter-base/arquillian-recorder-screenshooter-impl-base/src/main/java/org/arquillian/extension/recorder/screenshooter/impl/InTestScreenshotResourceReportObserver.java | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
| import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.screenshooter.Screenshot;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes; | /**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.screenshooter.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestScreenshotResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
public void onInTestResourceReport(@Observes InTestResourceReport event) {
TakenResourceRegister register = takenResourceRegister.get();
for (Screenshot screenshot : register.getTakenScreenshots()) {
if (!register.getReportedScreenshots().contains(screenshot)) {
PropertyEntry propertyEntry = new ScreenshotReportEntryBuilder() | // Path: arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/When.java
// public enum When {
//
// AFTER("after"),
// BEFORE("before"),
// FAILED("failed"),
// ON_EVERY_ACTION("onEveryAction"),
// IN_TEST("in_test");
//
// private final String name;
//
// When(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return name;
// }
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/InTestResourceReport.java
// public class InTestResourceReport {
//
// }
//
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/event/PropertyReportEvent.java
// public class PropertyReportEvent {
//
// private final PropertyEntry propertyEntry;
//
// /**
// *
// * @param propertyEntry property entry to hook into reporting tree from your extension
// * @throws IllegalArgumentException if {@code propertyEntry} is a null object
// */
// public PropertyReportEvent(PropertyEntry propertyEntry) {
// Validate.notNull(propertyEntry, "property entry can not be a null object");
// this.propertyEntry = propertyEntry;
// }
//
// public PropertyEntry getPropertyEntry() {
// return propertyEntry;
// }
// }
// Path: arquillian-recorder-screenshooter-base/arquillian-recorder-screenshooter-impl-base/src/main/java/org/arquillian/extension/recorder/screenshooter/impl/InTestScreenshotResourceReportObserver.java
import org.arquillian.extension.recorder.When;
import org.arquillian.extension.recorder.screenshooter.Screenshot;
import org.arquillian.recorder.reporter.PropertyEntry;
import org.arquillian.recorder.reporter.event.InTestResourceReport;
import org.arquillian.recorder.reporter.event.PropertyReportEvent;
import org.arquillian.recorder.reporter.impl.TakenResourceRegister;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
/**
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.extension.recorder.screenshooter.impl;
/**
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
public class InTestScreenshotResourceReportObserver {
@Inject
private Instance<TakenResourceRegister> takenResourceRegister;
@Inject
private Event<PropertyReportEvent> reportEvent;
public void onInTestResourceReport(@Observes InTestResourceReport event) {
TakenResourceRegister register = takenResourceRegister.get();
for (Screenshot screenshot : register.getTakenScreenshots()) {
if (!register.getReportedScreenshots().contains(screenshot)) {
PropertyEntry propertyEntry = new ScreenshotReportEntryBuilder() | .withWhen(When.IN_TEST) |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/FileEntry.java | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
| import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.recorder.reporter.PropertyEntry; | /*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents a report of some file resource which could be created as a result of a testing process.<br>
* <br>
* Must hold:
* <ul>
* <li>path</li>
* <li>type</li>
* </ul>
* Can hold:
* <ul>
* <li>size</li>
* <li>message</li>
* </ul>
*
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "file")
@XmlType(propOrder = { "path", "size", "type", "message" }) | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/PropertyEntry.java
// public abstract class PropertyEntry implements ReportEntry {
//
// @XmlTransient
// private final List<PropertyEntry> propertyEntries = new ArrayList<PropertyEntry>();
//
// @Override
// public List<PropertyEntry> getPropertyEntries() {
// return propertyEntries;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PropertyEntry that = (PropertyEntry) o;
//
// return propertyEntries.equals(that.propertyEntries);
//
// }
//
// @Override
// public int hashCode() {
// return propertyEntries.hashCode();
// }
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/FileEntry.java
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.recorder.reporter.PropertyEntry;
/*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry;
/**
* Represents a report of some file resource which could be created as a result of a testing process.<br>
* <br>
* Must hold:
* <ul>
* <li>path</li>
* <li>type</li>
* </ul>
* Can hold:
* <ul>
* <li>size</li>
* <li>message</li>
* </ul>
*
* @author <a href="[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "file")
@XmlType(propOrder = { "path", "size", "type", "message" }) | public class FileEntry extends PropertyEntry { |
arquillian/arquillian-recorder | arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/table/TableCellEntry.java | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/Reportable.java
// public interface Reportable {
//
// }
| import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.recorder.reporter.Reportable; | /*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry.table;
/**
*
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "cell")
@XmlType(propOrder = { "colspan", "rowspan", "content" }) | // Path: arquillian-recorder-reporter/arquillian-recorder-reporter-spi/src/main/java/org/arquillian/recorder/reporter/Reportable.java
// public interface Reportable {
//
// }
// Path: arquillian-recorder-reporter/arquillian-recorder-reporter-api/src/main/java/org/arquillian/recorder/reporter/model/entry/table/TableCellEntry.java
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.arquillian.recorder.reporter.Reportable;
/*
* JBoss, Home of Professional Open Source
* Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
package org.arquillian.recorder.reporter.model.entry.table;
/**
*
* @author <a href="mailto:[email protected]">Stefan Miklosovic</a>
*
*/
@XmlRootElement(name = "cell")
@XmlType(propOrder = { "colspan", "rowspan", "content" }) | public class TableCellEntry implements Reportable { |
googlecreativelab/justaline-android | app/src/main/java/com/arexperiments/justaline/GlobalRoomManager.java | // Path: app/src/main/java/com/arexperiments/justaline/model/RoomData.java
// public class RoomData {
//
// public String key;
//
// private Long timestamp;
//
// private Message message;
//
// public RoomData(String key, Long timestamp) {
// this.key = key;
// this.timestamp = timestamp;
//
// String messageString = key + "," + timestamp.toString();
// message = new Message(messageString.getBytes());
// }
//
// public RoomData(Message message) {
// this.message = message;
// String messageString = new String(message.getContent());
// String[] parts = messageString.split(",");
// if (parts.length == 2) {
// try {
// key = parts[0];
// timestamp = Long.parseLong(parts[1]);
// } catch (RuntimeException e) {
// throw new MalformedDataException(
// "Message does not meet format <int:code>,<long:timestamp>: "
// + messageString);
// }
// } else {
// throw new MalformedDataException(
// "Message does not meet format <code>,<timestamp>: " + messageString);
// }
// }
//
// public Message getMessage() {
// return message;
// }
//
// public String getKey() {
// return key;
// }
//
// public static class MalformedDataException extends RuntimeException {
//
// public MalformedDataException(String message) {
// super(message);
// }
// }
// }
| import android.content.Context;
import android.util.Log;
import com.arexperiments.justaline.model.RoomData;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener; | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.arexperiments.justaline;
/**
* Created by Kat on 4/10/18.
*/
public class GlobalRoomManager extends RoomManager {
private static final String TAG = "GlobalRoomManager";
private static String ROOT_GLOBAL_ROOM = "global_rooms/global_room";
private static String globalRoomName = "";
private DatabaseReference globalRoomRef;
private GlobalRoomListener globalRoomListener;
/**
* Default constructor for the FirebaseManager class.
*
* @param context The application context.
*/
public GlobalRoomManager(Context context) {
super(context);
}
public static void setGlobalRoomName(String name) {
Log.i(TAG, "Set global room name: " + name);
globalRoomName = name;
}
@Override | // Path: app/src/main/java/com/arexperiments/justaline/model/RoomData.java
// public class RoomData {
//
// public String key;
//
// private Long timestamp;
//
// private Message message;
//
// public RoomData(String key, Long timestamp) {
// this.key = key;
// this.timestamp = timestamp;
//
// String messageString = key + "," + timestamp.toString();
// message = new Message(messageString.getBytes());
// }
//
// public RoomData(Message message) {
// this.message = message;
// String messageString = new String(message.getContent());
// String[] parts = messageString.split(",");
// if (parts.length == 2) {
// try {
// key = parts[0];
// timestamp = Long.parseLong(parts[1]);
// } catch (RuntimeException e) {
// throw new MalformedDataException(
// "Message does not meet format <int:code>,<long:timestamp>: "
// + messageString);
// }
// } else {
// throw new MalformedDataException(
// "Message does not meet format <code>,<timestamp>: " + messageString);
// }
// }
//
// public Message getMessage() {
// return message;
// }
//
// public String getKey() {
// return key;
// }
//
// public static class MalformedDataException extends RuntimeException {
//
// public MalformedDataException(String message) {
// super(message);
// }
// }
// }
// Path: app/src/main/java/com/arexperiments/justaline/GlobalRoomManager.java
import android.content.Context;
import android.util.Log;
import com.arexperiments.justaline.model.RoomData;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.arexperiments.justaline;
/**
* Created by Kat on 4/10/18.
*/
public class GlobalRoomManager extends RoomManager {
private static final String TAG = "GlobalRoomManager";
private static String ROOT_GLOBAL_ROOM = "global_rooms/global_room";
private static String globalRoomName = "";
private DatabaseReference globalRoomRef;
private GlobalRoomListener globalRoomListener;
/**
* Default constructor for the FirebaseManager class.
*
* @param context The application context.
*/
public GlobalRoomManager(Context context) {
super(context);
}
public static void setGlobalRoomName(String name) {
Log.i(TAG, "Set global room name: " + name);
globalRoomName = name;
}
@Override | public boolean joinRoom(final RoomData roomData, final String uid, final boolean isPairing, |
googlecreativelab/justaline-android | app/src/main/java/com/arexperiments/justaline/PermissionsActivity.java | // Path: app/src/main/java/com/arexperiments/justaline/analytics/Fa.java
// public class Fa {
//
// private static final String TAG = "FirebaseAnalytics";
//
// private static Fa instance = null;
//
// private FirebaseAnalytics fa;
//
// public static Fa get() {
// if (instance == null) {
// instance = getSync();
// }
// return instance;
// }
//
// private static synchronized Fa getSync() {
// if (instance == null) {
// instance = new Fa();
// }
// return instance;
// }
//
// @SuppressWarnings("MissingPermission")
// private Fa() {
// if (!BuildConfig.DEBUG) {
//
// Log.d(TAG, "FirebaseAnalytics and FirebaseCrash active");
//
// // cache reference to FirebaseAnalytics
// fa = FirebaseAnalytics.getInstance(App.get());
//
// } else {
//
// Log.v(TAG, "FirebaseAnalytics and FirebaseCrash inactive");
// }
// }
//
// /**
// * Send an event along with an optional Bundle representing custom parameters
// */
// public void send(@NonNull String event, @Nullable Bundle customParams) {
// Log.v(TAG, event + " " + (customParams != null ? customParams : ""));
// if (fa == null) return;
//
// fa.logEvent(event, customParams);
// }
//
// /**
// * Send an event without any params
// */
// public void send(@NonNull String event) {
// Log.v(TAG, event);
// if (fa == null) return;
// send(event, null);
// }
//
// /**
// * Send an event along with one parameter whose value is a String (convenience method)
// */
// public void send(
// @NonNull String event,
// @NonNull String customParam1Name,
// @NonNull String customParam1Value) {
// Log.v(TAG, event + " " + customParam1Name + ": " + customParam1Value);
// if (fa == null) return;
// Bundle b = new Bundle();
// b.putString(customParam1Name, customParam1Value);
// send(event, b);
// }
//
// /**
// * Send an event along with one parameter whose value is an int (convenience method)
// */
// public void send(
// @NonNull String event,
// @NonNull String customParam1Name,
// int customParam1Value) {
// Bundle b = new Bundle();
// b.putInt(customParam1Name, customParam1Value);
// send(event, b);
// }
//
// /**
// * Send an event along with two parameters (whose values are Strings)
// * (convenience method)
// */
// public void send(
// @NonNull String event,
// @NonNull String customParam1Name,
// @NonNull String customParam1Value,
// @NonNull String customParam2Name,
// @NonNull String customParam2Value) {
// Bundle b = new Bundle();
// b.putString(customParam1Name, customParam1Value);
// b.putString(customParam2Name, customParam2Value);
// send(event, b);
// }
//
// /**
// * Send a caught exception to Firebase
// */
// public void exception(Throwable throwable) {
// Log.e(TAG, "Exception: ", throwable);
// if (BuildConfig.DEBUG) {
// return;
// }
// FirebaseCrash.report(throwable);
// }
//
// /**
// * Send a caught exception to Firebase with an additional logged message
// */
// public void exception(Throwable throwable, String logMessage) {
// Log.e(TAG, "Exception: " + throwable + " | " + logMessage, throwable);
// if (BuildConfig.DEBUG) {
// return;
// }
//
// FirebaseCrash.logcat(Log.WARN, TAG, logMessage);
// FirebaseCrash.report(throwable);
// }
//
// /**
// * Sets the value of a Firebase Analytics custom user property. That property must already be
// * set
// * up in the console. Note that the value that is set is 'persistent' across user sessions.
// */
// public void setUserProperty(String property, String value) {
// Log.d(TAG, property + " = " + value);
// if (fa == null) {
// return;
// }
// fa.setUserProperty(property, value);
// }
// }
| import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.util.Log;
import android.widget.Toast;
import com.arexperiments.justaline.analytics.Fa;
import com.google.ar.core.ArCoreApk; | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.arexperiments.justaline;
public class PermissionsActivity extends BaseActivity {
private static final String TAG = "PermissionsActivity";
@SuppressWarnings("FieldCanBeLocal")
private final int SPLASH_DISPLAY_LENGTH = 2000;
| // Path: app/src/main/java/com/arexperiments/justaline/analytics/Fa.java
// public class Fa {
//
// private static final String TAG = "FirebaseAnalytics";
//
// private static Fa instance = null;
//
// private FirebaseAnalytics fa;
//
// public static Fa get() {
// if (instance == null) {
// instance = getSync();
// }
// return instance;
// }
//
// private static synchronized Fa getSync() {
// if (instance == null) {
// instance = new Fa();
// }
// return instance;
// }
//
// @SuppressWarnings("MissingPermission")
// private Fa() {
// if (!BuildConfig.DEBUG) {
//
// Log.d(TAG, "FirebaseAnalytics and FirebaseCrash active");
//
// // cache reference to FirebaseAnalytics
// fa = FirebaseAnalytics.getInstance(App.get());
//
// } else {
//
// Log.v(TAG, "FirebaseAnalytics and FirebaseCrash inactive");
// }
// }
//
// /**
// * Send an event along with an optional Bundle representing custom parameters
// */
// public void send(@NonNull String event, @Nullable Bundle customParams) {
// Log.v(TAG, event + " " + (customParams != null ? customParams : ""));
// if (fa == null) return;
//
// fa.logEvent(event, customParams);
// }
//
// /**
// * Send an event without any params
// */
// public void send(@NonNull String event) {
// Log.v(TAG, event);
// if (fa == null) return;
// send(event, null);
// }
//
// /**
// * Send an event along with one parameter whose value is a String (convenience method)
// */
// public void send(
// @NonNull String event,
// @NonNull String customParam1Name,
// @NonNull String customParam1Value) {
// Log.v(TAG, event + " " + customParam1Name + ": " + customParam1Value);
// if (fa == null) return;
// Bundle b = new Bundle();
// b.putString(customParam1Name, customParam1Value);
// send(event, b);
// }
//
// /**
// * Send an event along with one parameter whose value is an int (convenience method)
// */
// public void send(
// @NonNull String event,
// @NonNull String customParam1Name,
// int customParam1Value) {
// Bundle b = new Bundle();
// b.putInt(customParam1Name, customParam1Value);
// send(event, b);
// }
//
// /**
// * Send an event along with two parameters (whose values are Strings)
// * (convenience method)
// */
// public void send(
// @NonNull String event,
// @NonNull String customParam1Name,
// @NonNull String customParam1Value,
// @NonNull String customParam2Name,
// @NonNull String customParam2Value) {
// Bundle b = new Bundle();
// b.putString(customParam1Name, customParam1Value);
// b.putString(customParam2Name, customParam2Value);
// send(event, b);
// }
//
// /**
// * Send a caught exception to Firebase
// */
// public void exception(Throwable throwable) {
// Log.e(TAG, "Exception: ", throwable);
// if (BuildConfig.DEBUG) {
// return;
// }
// FirebaseCrash.report(throwable);
// }
//
// /**
// * Send a caught exception to Firebase with an additional logged message
// */
// public void exception(Throwable throwable, String logMessage) {
// Log.e(TAG, "Exception: " + throwable + " | " + logMessage, throwable);
// if (BuildConfig.DEBUG) {
// return;
// }
//
// FirebaseCrash.logcat(Log.WARN, TAG, logMessage);
// FirebaseCrash.report(throwable);
// }
//
// /**
// * Sets the value of a Firebase Analytics custom user property. That property must already be
// * set
// * up in the console. Note that the value that is set is 'persistent' across user sessions.
// */
// public void setUserProperty(String property, String value) {
// Log.d(TAG, property + " = " + value);
// if (fa == null) {
// return;
// }
// fa.setUserProperty(property, value);
// }
// }
// Path: app/src/main/java/com/arexperiments/justaline/PermissionsActivity.java
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.util.Log;
import android.widget.Toast;
import com.arexperiments.justaline.analytics.Fa;
import com.google.ar.core.ArCoreApk;
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.arexperiments.justaline;
public class PermissionsActivity extends BaseActivity {
private static final String TAG = "PermissionsActivity";
@SuppressWarnings("FieldCanBeLocal")
private final int SPLASH_DISPLAY_LENGTH = 2000;
| private Fa mAnalytics; |
googlecreativelab/justaline-android | app/src/main/java/com/arexperiments/justaline/view/BrushSelector.java | // Path: app/src/main/java/com/arexperiments/justaline/AppSettings.java
// public class AppSettings {
//
// private static final Vector3f color = new Vector3f(1f, 1f, 1f);
//
// private static final float strokeDrawDistance = 0.13f;
//
// private static final float minDistance = 0.000001f;
//
// private static final float nearClip = 0.001f;
//
// private static final float farClip = 100.0f;
//
// private static final float smoothing = 0.07f;
//
// private static final int smoothingCount = 1500;
//
// public enum LineWidth {
// SMALL(0.006f),
// MEDIUM(0.011f),
// LARGE(0.020f);
//
// private final float width;
//
// LineWidth(float i) {
// this.width = i;
// }
//
// public float getWidth() {
// return width;
// }
// }
//
// public static float getStrokeDrawDistance() {
// return strokeDrawDistance;
// }
//
// public static Vector3f getColor() {
// return color;
// }
//
// public static float getMinDistance() {
// return minDistance;
// }
//
// static float getNearClip() {
// return nearClip;
// }
//
// static float getFarClip() {
// return farClip;
// }
//
// public static float getSmoothing() {
// return smoothing;
// }
//
// public static int getSmoothingCount() {
// return smoothingCount;
// }
// }
| import android.animation.Animator;
import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import com.arexperiments.justaline.AppSettings;
import com.arexperiments.justaline.R; | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.arexperiments.justaline.view;
/**
* Created by Kat on 11/13/17.
* Custom view for selecting brush size
*/
public class BrushSelector extends ConstraintLayout implements View.OnClickListener {
private static final String TAG = "BrushSelector";
private static final int SMALL_BRUSH = 0;
private static final int MEDIUM_BRUSH = 1;
private static final int LARGE_BRUSH = 2;
| // Path: app/src/main/java/com/arexperiments/justaline/AppSettings.java
// public class AppSettings {
//
// private static final Vector3f color = new Vector3f(1f, 1f, 1f);
//
// private static final float strokeDrawDistance = 0.13f;
//
// private static final float minDistance = 0.000001f;
//
// private static final float nearClip = 0.001f;
//
// private static final float farClip = 100.0f;
//
// private static final float smoothing = 0.07f;
//
// private static final int smoothingCount = 1500;
//
// public enum LineWidth {
// SMALL(0.006f),
// MEDIUM(0.011f),
// LARGE(0.020f);
//
// private final float width;
//
// LineWidth(float i) {
// this.width = i;
// }
//
// public float getWidth() {
// return width;
// }
// }
//
// public static float getStrokeDrawDistance() {
// return strokeDrawDistance;
// }
//
// public static Vector3f getColor() {
// return color;
// }
//
// public static float getMinDistance() {
// return minDistance;
// }
//
// static float getNearClip() {
// return nearClip;
// }
//
// static float getFarClip() {
// return farClip;
// }
//
// public static float getSmoothing() {
// return smoothing;
// }
//
// public static int getSmoothingCount() {
// return smoothingCount;
// }
// }
// Path: app/src/main/java/com/arexperiments/justaline/view/BrushSelector.java
import android.animation.Animator;
import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import com.arexperiments.justaline.AppSettings;
import com.arexperiments.justaline.R;
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.arexperiments.justaline.view;
/**
* Created by Kat on 11/13/17.
* Custom view for selecting brush size
*/
public class BrushSelector extends ConstraintLayout implements View.OnClickListener {
private static final String TAG = "BrushSelector";
private static final int SMALL_BRUSH = 0;
private static final int MEDIUM_BRUSH = 1;
private static final int LARGE_BRUSH = 2;
| private static final Pair<Integer, AppSettings.LineWidth> defaultBrush = new Pair<>(MEDIUM_BRUSH, |
googlecreativelab/justaline-android | app/src/main/java/com/arexperiments/justaline/analytics/Fa.java | // Path: app/src/main/java/com/arexperiments/justaline/App.java
// public class App extends Application {
//
// private static App instance = null;
//
// public App() {
// instance = this;
// }
//
// public static App get() {
// return instance;
// }
//
//
// public static boolean isOnline() {
// ConnectivityManager cm =
// (ConnectivityManager) get().getSystemService(Context.CONNECTIVITY_SERVICE);
//
// NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
// return activeNetwork != null &&
// activeNetwork.isConnectedOrConnecting();
//
// }
//
// }
| import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import com.arexperiments.justaline.App;
import com.arexperiments.justaline.BuildConfig;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.crash.FirebaseCrash; | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.arexperiments.justaline.analytics;
/**
* Firebase Analytics wrapper class (hence "Fa").
*/
public class Fa {
private static final String TAG = "FirebaseAnalytics";
private static Fa instance = null;
private FirebaseAnalytics fa;
public static Fa get() {
if (instance == null) {
instance = getSync();
}
return instance;
}
private static synchronized Fa getSync() {
if (instance == null) {
instance = new Fa();
}
return instance;
}
@SuppressWarnings("MissingPermission")
private Fa() {
if (!BuildConfig.DEBUG) {
Log.d(TAG, "FirebaseAnalytics and FirebaseCrash active");
// cache reference to FirebaseAnalytics | // Path: app/src/main/java/com/arexperiments/justaline/App.java
// public class App extends Application {
//
// private static App instance = null;
//
// public App() {
// instance = this;
// }
//
// public static App get() {
// return instance;
// }
//
//
// public static boolean isOnline() {
// ConnectivityManager cm =
// (ConnectivityManager) get().getSystemService(Context.CONNECTIVITY_SERVICE);
//
// NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
// return activeNetwork != null &&
// activeNetwork.isConnectedOrConnecting();
//
// }
//
// }
// Path: app/src/main/java/com/arexperiments/justaline/analytics/Fa.java
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import com.arexperiments.justaline.App;
import com.arexperiments.justaline.BuildConfig;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.crash.FirebaseCrash;
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.arexperiments.justaline.analytics;
/**
* Firebase Analytics wrapper class (hence "Fa").
*/
public class Fa {
private static final String TAG = "FirebaseAnalytics";
private static Fa instance = null;
private FirebaseAnalytics fa;
public static Fa get() {
if (instance == null) {
instance = getSync();
}
return instance;
}
private static synchronized Fa getSync() {
if (instance == null) {
instance = new Fa();
}
return instance;
}
@SuppressWarnings("MissingPermission")
private Fa() {
if (!BuildConfig.DEBUG) {
Log.d(TAG, "FirebaseAnalytics and FirebaseCrash active");
// cache reference to FirebaseAnalytics | fa = FirebaseAnalytics.getInstance(App.get()); |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitImporter.java | // Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/HttpSessionProvider.java
// public abstract class HttpSessionProvider<T> implements ScopedProvider<T> {
//
// @Inject private Provider<T> provider;
//
// @Inject private Provider<HttpServletRequest> httpRequestProvider;
//
// @Override
// public T get() {
// return get(httpRequestProvider.get());
// }
//
// @Override
// public T get(final HttpServletRequest req) {
// HttpSession session = req.getSession();
// String singletonKey = getClass().getName();
//
// synchronized (this) {
// @SuppressWarnings("unchecked")
// T instance = (T) session.getAttribute(singletonKey);
// if (instance == null) {
// instance = provider.get();
// session.setAttribute(singletonKey, instance);
// }
// return instance;
// }
// }
//
// @Override
// public HttpServletRequest getScopedRequest() {
// return httpRequestProvider.get();
// }
// }
| import com.google.gerrit.server.IdentifiedUser;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.github.oauth.HttpSessionProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | // Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.git;
public class GitImporter extends BatchImporter {
@Singleton | // Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/HttpSessionProvider.java
// public abstract class HttpSessionProvider<T> implements ScopedProvider<T> {
//
// @Inject private Provider<T> provider;
//
// @Inject private Provider<HttpServletRequest> httpRequestProvider;
//
// @Override
// public T get() {
// return get(httpRequestProvider.get());
// }
//
// @Override
// public T get(final HttpServletRequest req) {
// HttpSession session = req.getSession();
// String singletonKey = getClass().getName();
//
// synchronized (this) {
// @SuppressWarnings("unchecked")
// T instance = (T) session.getAttribute(singletonKey);
// if (instance == null) {
// instance = provider.get();
// session.setAttribute(singletonKey, instance);
// }
// return instance;
// }
// }
//
// @Override
// public HttpServletRequest getScopedRequest() {
// return httpRequestProvider.get();
// }
// }
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitImporter.java
import com.google.gerrit.server.IdentifiedUser;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.github.oauth.HttpSessionProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.git;
public class GitImporter extends BatchImporter {
@Singleton | public static class Provider extends HttpSessionProvider<GitImporter> {} |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/JobExecutor.java | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/GitHubConfig.java
// @Singleton
// public class GitHubConfig extends GitHubOAuthConfig {
//
// private static final String CONF_WIZARD_FLOW = "wizardFlow";
// private HashMap<String, NextPage> wizardFromTo = Maps.newHashMap();
// private static final String FROM_TO_SEPARATOR = "=>";
// private static final String FROM_TO_REDIRECT_SEPARATOR = "R>";
// private static final String CONF_JOB_POOL_LIMIT = "jobPoolLimit";
// private static final String CONF_JOB_EXEC_TIMEOUT = "jobExecTimeout";
// private static final String CONF_PULL_REQUEST_LIST_LIMIT = "pullRequestListLimit";
// private static final String CONF_REPOSITORY_LIST_PAGE_SIZE = "repositoryListPageSize";
// private static final String CONF_REPOSITORY_LIST_LIMIT = "repositoryListLimit";
// private static final String CONF_PUBLIC_BASE_PROJECT = "publicBaseProject";
// private static final String CONF_PRIVATE_BASE_PROJECT = "privateBaseProject";
// private static final String CONF_WEBHOOK_SECRET = "webhookSecret";
// private static final String CONF_WEBHOOK_USER = "webhookUser";
// private static final String CONF_IMPORT_ACCOUNT_ID = "importAccountId";
//
// public final Path gitDir;
// public final int jobPoolLimit;
// public final int jobExecTimeout;
// public final int pullRequestListLimit;
// public final int repositoryListPageSize;
// public final int repositoryListLimit;
// public final String privateBaseProject;
// public final String publicBaseProject;
// public final String allProjectsName;
// public final String webhookSecret;
// public final String webhookUser;
// public final Account.Id importAccountId;
//
// public static class NextPage {
// public final String uri;
// public final boolean redirect;
//
// public NextPage(final String pageUri, final boolean redirect) {
// this.uri = pageUri;
// this.redirect = redirect;
// }
// }
//
// @Inject
// public GitHubConfig(
// @GerritServerConfig Config config,
// final SitePaths site,
// AllProjectsNameProvider allProjectsNameProvider,
// CanonicalWebUrl canonicalWebUrl,
// AuthConfig authConfig)
// throws MalformedURLException {
// super(config, canonicalWebUrl, authConfig);
// String[] wizardFlows = config.getStringList(CONF_SECTION, null, CONF_WIZARD_FLOW);
// for (String fromTo : wizardFlows) {
// boolean redirect = fromTo.indexOf(FROM_TO_REDIRECT_SEPARATOR) > 0;
// int sepPos = getSepPos(fromTo, redirect);
// String fromPage = fromTo.substring(0, sepPos).trim();
// NextPage toPage =
// new NextPage(
// fromTo.substring(sepPos + getSeparator(redirect).length() + 1).trim(), redirect);
// wizardFromTo.put(fromPage, toPage);
// }
//
// jobPoolLimit = config.getInt(CONF_SECTION, CONF_JOB_POOL_LIMIT, 5);
// jobExecTimeout = config.getInt(CONF_SECTION, CONF_JOB_EXEC_TIMEOUT, 10);
// pullRequestListLimit = config.getInt(CONF_SECTION, CONF_PULL_REQUEST_LIST_LIMIT, 50);
// repositoryListPageSize = config.getInt(CONF_SECTION, CONF_REPOSITORY_LIST_PAGE_SIZE, 50);
// repositoryListLimit = config.getInt(CONF_SECTION, CONF_REPOSITORY_LIST_LIMIT, 50);
//
// gitDir = site.resolve(config.getString("gerrit", null, "basePath"));
// if (gitDir == null) {
// throw new IllegalStateException("gerrit.basePath must be configured");
// }
//
// privateBaseProject = config.getString(CONF_SECTION, null, CONF_PRIVATE_BASE_PROJECT);
// publicBaseProject = config.getString(CONF_SECTION, null, CONF_PUBLIC_BASE_PROJECT);
// allProjectsName = allProjectsNameProvider.get().toString();
// webhookSecret = config.getString(CONF_SECTION, null, CONF_WEBHOOK_SECRET);
// webhookUser = config.getString(CONF_SECTION, null, CONF_WEBHOOK_USER);
// importAccountId = Account.id(config.getInt(CONF_SECTION, CONF_IMPORT_ACCOUNT_ID, 1000000));
// }
//
// private String getSeparator(boolean redirect) {
// String separator = redirect ? FROM_TO_REDIRECT_SEPARATOR : FROM_TO_SEPARATOR;
// return separator;
// }
//
// private int getSepPos(String fromTo, boolean redirect) {
// int sepPos = fromTo.indexOf(getSeparator(redirect));
// if (sepPos < 0) {
// throw new InvalidGitHubConfigException(fromTo);
// }
// return sepPos;
// }
//
// public NextPage getNextPage(String sourcePage) {
// return wizardFromTo.get(sourcePage);
// }
//
// public String getBaseProject(boolean isPrivateProject) {
// return MoreObjects.firstNonNull(
// isPrivateProject ? privateBaseProject : publicBaseProject, allProjectsName);
// }
// }
| import com.google.gerrit.server.util.RequestScopePropagator;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.github.GitHubConfig;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; | // Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.git;
@Singleton
public class JobExecutor {
private final ScheduledExecutorService executor;
private final RequestScopePropagator requestScopePropagator; | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/GitHubConfig.java
// @Singleton
// public class GitHubConfig extends GitHubOAuthConfig {
//
// private static final String CONF_WIZARD_FLOW = "wizardFlow";
// private HashMap<String, NextPage> wizardFromTo = Maps.newHashMap();
// private static final String FROM_TO_SEPARATOR = "=>";
// private static final String FROM_TO_REDIRECT_SEPARATOR = "R>";
// private static final String CONF_JOB_POOL_LIMIT = "jobPoolLimit";
// private static final String CONF_JOB_EXEC_TIMEOUT = "jobExecTimeout";
// private static final String CONF_PULL_REQUEST_LIST_LIMIT = "pullRequestListLimit";
// private static final String CONF_REPOSITORY_LIST_PAGE_SIZE = "repositoryListPageSize";
// private static final String CONF_REPOSITORY_LIST_LIMIT = "repositoryListLimit";
// private static final String CONF_PUBLIC_BASE_PROJECT = "publicBaseProject";
// private static final String CONF_PRIVATE_BASE_PROJECT = "privateBaseProject";
// private static final String CONF_WEBHOOK_SECRET = "webhookSecret";
// private static final String CONF_WEBHOOK_USER = "webhookUser";
// private static final String CONF_IMPORT_ACCOUNT_ID = "importAccountId";
//
// public final Path gitDir;
// public final int jobPoolLimit;
// public final int jobExecTimeout;
// public final int pullRequestListLimit;
// public final int repositoryListPageSize;
// public final int repositoryListLimit;
// public final String privateBaseProject;
// public final String publicBaseProject;
// public final String allProjectsName;
// public final String webhookSecret;
// public final String webhookUser;
// public final Account.Id importAccountId;
//
// public static class NextPage {
// public final String uri;
// public final boolean redirect;
//
// public NextPage(final String pageUri, final boolean redirect) {
// this.uri = pageUri;
// this.redirect = redirect;
// }
// }
//
// @Inject
// public GitHubConfig(
// @GerritServerConfig Config config,
// final SitePaths site,
// AllProjectsNameProvider allProjectsNameProvider,
// CanonicalWebUrl canonicalWebUrl,
// AuthConfig authConfig)
// throws MalformedURLException {
// super(config, canonicalWebUrl, authConfig);
// String[] wizardFlows = config.getStringList(CONF_SECTION, null, CONF_WIZARD_FLOW);
// for (String fromTo : wizardFlows) {
// boolean redirect = fromTo.indexOf(FROM_TO_REDIRECT_SEPARATOR) > 0;
// int sepPos = getSepPos(fromTo, redirect);
// String fromPage = fromTo.substring(0, sepPos).trim();
// NextPage toPage =
// new NextPage(
// fromTo.substring(sepPos + getSeparator(redirect).length() + 1).trim(), redirect);
// wizardFromTo.put(fromPage, toPage);
// }
//
// jobPoolLimit = config.getInt(CONF_SECTION, CONF_JOB_POOL_LIMIT, 5);
// jobExecTimeout = config.getInt(CONF_SECTION, CONF_JOB_EXEC_TIMEOUT, 10);
// pullRequestListLimit = config.getInt(CONF_SECTION, CONF_PULL_REQUEST_LIST_LIMIT, 50);
// repositoryListPageSize = config.getInt(CONF_SECTION, CONF_REPOSITORY_LIST_PAGE_SIZE, 50);
// repositoryListLimit = config.getInt(CONF_SECTION, CONF_REPOSITORY_LIST_LIMIT, 50);
//
// gitDir = site.resolve(config.getString("gerrit", null, "basePath"));
// if (gitDir == null) {
// throw new IllegalStateException("gerrit.basePath must be configured");
// }
//
// privateBaseProject = config.getString(CONF_SECTION, null, CONF_PRIVATE_BASE_PROJECT);
// publicBaseProject = config.getString(CONF_SECTION, null, CONF_PUBLIC_BASE_PROJECT);
// allProjectsName = allProjectsNameProvider.get().toString();
// webhookSecret = config.getString(CONF_SECTION, null, CONF_WEBHOOK_SECRET);
// webhookUser = config.getString(CONF_SECTION, null, CONF_WEBHOOK_USER);
// importAccountId = Account.id(config.getInt(CONF_SECTION, CONF_IMPORT_ACCOUNT_ID, 1000000));
// }
//
// private String getSeparator(boolean redirect) {
// String separator = redirect ? FROM_TO_REDIRECT_SEPARATOR : FROM_TO_SEPARATOR;
// return separator;
// }
//
// private int getSepPos(String fromTo, boolean redirect) {
// int sepPos = fromTo.indexOf(getSeparator(redirect));
// if (sepPos < 0) {
// throw new InvalidGitHubConfigException(fromTo);
// }
// return sepPos;
// }
//
// public NextPage getNextPage(String sourcePage) {
// return wizardFromTo.get(sourcePage);
// }
//
// public String getBaseProject(boolean isPrivateProject) {
// return MoreObjects.firstNonNull(
// isPrivateProject ? privateBaseProject : publicBaseProject, allProjectsName);
// }
// }
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/JobExecutor.java
import com.google.gerrit.server.util.RequestScopePropagator;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.github.GitHubConfig;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.git;
@Singleton
public class JobExecutor {
private final ScheduledExecutorService executor;
private final RequestScopePropagator requestScopePropagator; | private final GitHubConfig config; |
GerritCodeReview/plugins_github | github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthCache.java | // Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthProtocol.java
// public static class AccessToken {
// public String accessToken;
// public String tokenType;
// public String error;
// public String errorDescription;
// public String errorUri;
// public String raw;
//
// public AccessToken() {}
//
// public AccessToken(String token) {
// this(token, "");
// }
//
// public AccessToken(String token, String type) {
// this();
// this.accessToken = token;
// this.tokenType = type;
// }
//
// @Override
// public String toString() {
// if (isError()) {
// return "Error AccessToken [error="
// + error
// + ", error_description="
// + errorDescription
// + ", error_uri="
// + errorUri
// + "]";
// }
// return "AccessToken [access_token=" + accessToken + ", token_type=" + tokenType + "]";
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(accessToken, tokenType, error, errorDescription, errorUri);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final AccessToken other = (AccessToken) obj;
// return Objects.equals(this.accessToken, other.accessToken)
// && Objects.equals(this.raw, other.raw)
// && Objects.equals(this.tokenType, other.tokenType);
// }
//
// public boolean isError() {
// return !Strings.isNullOrEmpty(error);
// }
//
// public String getRaw() {
// return raw;
// }
//
// public void setRaw(String raw) {
// this.raw = raw;
// }
//
// public OAuthToken toOAuthToken() {
// return new OAuthToken(accessToken, null, getRaw());
// }
// }
| import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.gerrit.server.cache.CacheModule;
import com.google.inject.Inject;
import com.google.inject.Module;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.googlesource.gerrit.plugins.github.oauth.OAuthProtocol.AccessToken;
import java.util.concurrent.ExecutionException; | // Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.oauth;
@Singleton
public class OAuthCache {
private static final String CACHE_NAME = "github_oauth";
| // Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthProtocol.java
// public static class AccessToken {
// public String accessToken;
// public String tokenType;
// public String error;
// public String errorDescription;
// public String errorUri;
// public String raw;
//
// public AccessToken() {}
//
// public AccessToken(String token) {
// this(token, "");
// }
//
// public AccessToken(String token, String type) {
// this();
// this.accessToken = token;
// this.tokenType = type;
// }
//
// @Override
// public String toString() {
// if (isError()) {
// return "Error AccessToken [error="
// + error
// + ", error_description="
// + errorDescription
// + ", error_uri="
// + errorUri
// + "]";
// }
// return "AccessToken [access_token=" + accessToken + ", token_type=" + tokenType + "]";
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(accessToken, tokenType, error, errorDescription, errorUri);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final AccessToken other = (AccessToken) obj;
// return Objects.equals(this.accessToken, other.accessToken)
// && Objects.equals(this.raw, other.raw)
// && Objects.equals(this.tokenType, other.tokenType);
// }
//
// public boolean isError() {
// return !Strings.isNullOrEmpty(error);
// }
//
// public String getRaw() {
// return raw;
// }
//
// public void setRaw(String raw) {
// this.raw = raw;
// }
//
// public OAuthToken toOAuthToken() {
// return new OAuthToken(accessToken, null, getRaw());
// }
// }
// Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthCache.java
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.gerrit.server.cache.CacheModule;
import com.google.inject.Inject;
import com.google.inject.Module;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.googlesource.gerrit.plugins.github.oauth.OAuthProtocol.AccessToken;
import java.util.concurrent.ExecutionException;
// Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.oauth;
@Singleton
public class OAuthCache {
private static final String CACHE_NAME = "github_oauth";
| public static class Loader extends CacheLoader<AccessToken, String> { |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitImportJob.java | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJobStatus.java
// public enum Code {
// SYNC,
// COMPLETE,
// FAILED,
// CANCELLED;
//
// @Override
// public String toString() {
// return name().toLowerCase();
// }
// }
| import org.eclipse.jgit.lib.ProgressMonitor;
import com.googlesource.gerrit.plugins.github.git.GitJobStatus.Code; | // Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.git;
public class GitImportJob extends AbstractCloneJob implements Runnable, ProgressMonitor, GitJob {
private int currTask;
private int totUnits;
private int currUnit;
private int lastPercentage;
private boolean cancelled;
private String task = "Waiting ...";
private Exception exception;
private GitJobStatus status;
private int index;
private final ImportStep[] importSteps;
private String organisation;
private String repository;
public GitImportJob(int id, String organisation, String repository, ImportStep... steps) {
this.importSteps = steps;
this.index = id;
this.organisation = organisation;
this.repository = repository;
this.status = new GitJobStatus(id);
}
@Override
public void run() {
try { | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJobStatus.java
// public enum Code {
// SYNC,
// COMPLETE,
// FAILED,
// CANCELLED;
//
// @Override
// public String toString() {
// return name().toLowerCase();
// }
// }
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitImportJob.java
import org.eclipse.jgit.lib.ProgressMonitor;
import com.googlesource.gerrit.plugins.github.git.GitJobStatus.Code;
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.git;
public class GitImportJob extends AbstractCloneJob implements Runnable, ProgressMonitor, GitJob {
private int currTask;
private int totUnits;
private int currUnit;
private int lastPercentage;
private boolean cancelled;
private String task = "Waiting ...";
private Exception exception;
private GitJobStatus status;
private int index;
private final ImportStep[] importSteps;
private String organisation;
private String repository;
public GitImportJob(int id, String organisation, String repository, ImportStep... steps) {
this.importSteps = steps;
this.index = id;
this.organisation = organisation;
this.repository = repository;
this.status = new GitJobStatus(id);
}
@Override
public void run() {
try { | status.update(Code.SYNC, "Init", "Initializing import steps ..."); |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java
// public static final String NAME_PREFIX = "github/";
//
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java
// public static final String UUID_PREFIX = "github:";
| import static com.google.common.base.Preconditions.checkArgument;
import static com.googlesource.gerrit.plugins.github.group.GitHubGroup.NAME_PREFIX;
import static com.googlesource.gerrit.plugins.github.group.GitHubGroup.UUID_PREFIX;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.gerrit.entities.AccountGroup;
import com.google.gerrit.entities.AccountGroup.UUID;
import com.google.gerrit.entities.GroupDescription.Basic;
import com.google.gerrit.entities.GroupReference;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Inject;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | // Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.group;
public class GitHubGroupBackend implements GroupBackend {
private static final Logger log = LoggerFactory.getLogger(GitHubGroupBackend.class);
private final GitHubGroupMembership.Factory ghMembershipProvider;
private final GitHubGroupsCache ghOrganisationCache;
@Inject
GitHubGroupBackend(
GitHubGroupMembership.Factory ghMembershipProvider, GitHubGroupsCache ghOrganisationCache) {
this.ghMembershipProvider = ghMembershipProvider;
this.ghOrganisationCache = ghOrganisationCache;
}
@Override
public boolean isVisibleToAll(AccountGroup.UUID uuid) {
return true;
}
@Override
public boolean handles(UUID uuid) { | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java
// public static final String NAME_PREFIX = "github/";
//
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java
// public static final String UUID_PREFIX = "github:";
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java
import static com.google.common.base.Preconditions.checkArgument;
import static com.googlesource.gerrit.plugins.github.group.GitHubGroup.NAME_PREFIX;
import static com.googlesource.gerrit.plugins.github.group.GitHubGroup.UUID_PREFIX;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.gerrit.entities.AccountGroup;
import com.google.gerrit.entities.AccountGroup.UUID;
import com.google.gerrit.entities.GroupDescription.Basic;
import com.google.gerrit.entities.GroupReference;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Inject;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.group;
public class GitHubGroupBackend implements GroupBackend {
private static final Logger log = LoggerFactory.getLogger(GitHubGroupBackend.class);
private final GitHubGroupMembership.Factory ghMembershipProvider;
private final GitHubGroupsCache ghOrganisationCache;
@Inject
GitHubGroupBackend(
GitHubGroupMembership.Factory ghMembershipProvider, GitHubGroupsCache ghOrganisationCache) {
this.ghMembershipProvider = ghMembershipProvider;
this.ghOrganisationCache = ghOrganisationCache;
}
@Override
public boolean isVisibleToAll(AccountGroup.UUID uuid) {
return true;
}
@Override
public boolean handles(UUID uuid) { | return uuid.get().startsWith(UUID_PREFIX); |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java
// public static final String NAME_PREFIX = "github/";
//
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java
// public static final String UUID_PREFIX = "github:";
| import static com.google.common.base.Preconditions.checkArgument;
import static com.googlesource.gerrit.plugins.github.group.GitHubGroup.NAME_PREFIX;
import static com.googlesource.gerrit.plugins.github.group.GitHubGroup.UUID_PREFIX;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.gerrit.entities.AccountGroup;
import com.google.gerrit.entities.AccountGroup.UUID;
import com.google.gerrit.entities.GroupDescription.Basic;
import com.google.gerrit.entities.GroupReference;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Inject;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | // Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.group;
public class GitHubGroupBackend implements GroupBackend {
private static final Logger log = LoggerFactory.getLogger(GitHubGroupBackend.class);
private final GitHubGroupMembership.Factory ghMembershipProvider;
private final GitHubGroupsCache ghOrganisationCache;
@Inject
GitHubGroupBackend(
GitHubGroupMembership.Factory ghMembershipProvider, GitHubGroupsCache ghOrganisationCache) {
this.ghMembershipProvider = ghMembershipProvider;
this.ghOrganisationCache = ghOrganisationCache;
}
@Override
public boolean isVisibleToAll(AccountGroup.UUID uuid) {
return true;
}
@Override
public boolean handles(UUID uuid) {
return uuid.get().startsWith(UUID_PREFIX);
}
@Override
public Basic get(UUID uuid) {
checkArgument(handles(uuid), "{} is not a valid GitHub Group UUID", uuid.get());
return GitHubOrganisationGroup.fromUUID(uuid);
}
@Override
public Collection<GroupReference> suggest(String name, ProjectState project) { | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java
// public static final String NAME_PREFIX = "github/";
//
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroup.java
// public static final String UUID_PREFIX = "github:";
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java
import static com.google.common.base.Preconditions.checkArgument;
import static com.googlesource.gerrit.plugins.github.group.GitHubGroup.NAME_PREFIX;
import static com.googlesource.gerrit.plugins.github.group.GitHubGroup.UUID_PREFIX;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.gerrit.entities.AccountGroup;
import com.google.gerrit.entities.AccountGroup.UUID;
import com.google.gerrit.entities.GroupDescription.Basic;
import com.google.gerrit.entities.GroupReference;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Inject;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.group;
public class GitHubGroupBackend implements GroupBackend {
private static final Logger log = LoggerFactory.getLogger(GitHubGroupBackend.class);
private final GitHubGroupMembership.Factory ghMembershipProvider;
private final GitHubGroupsCache ghOrganisationCache;
@Inject
GitHubGroupBackend(
GitHubGroupMembership.Factory ghMembershipProvider, GitHubGroupsCache ghOrganisationCache) {
this.ghMembershipProvider = ghMembershipProvider;
this.ghOrganisationCache = ghOrganisationCache;
}
@Override
public boolean isVisibleToAll(AccountGroup.UUID uuid) {
return true;
}
@Override
public boolean handles(UUID uuid) {
return uuid.get().startsWith(UUID_PREFIX);
}
@Override
public Basic get(UUID uuid) {
checkArgument(handles(uuid), "{} is not a valid GitHub Group UUID", uuid.get());
return GitHubOrganisationGroup.fromUUID(uuid);
}
@Override
public Collection<GroupReference> suggest(String name, ProjectState project) { | if (!name.startsWith(NAME_PREFIX)) { |
GerritCodeReview/plugins_github | github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/IdentifiedUserGitHubLoginProvider.java | // Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthProtocol.java
// public static class AccessToken {
// public String accessToken;
// public String tokenType;
// public String error;
// public String errorDescription;
// public String errorUri;
// public String raw;
//
// public AccessToken() {}
//
// public AccessToken(String token) {
// this(token, "");
// }
//
// public AccessToken(String token, String type) {
// this();
// this.accessToken = token;
// this.tokenType = type;
// }
//
// @Override
// public String toString() {
// if (isError()) {
// return "Error AccessToken [error="
// + error
// + ", error_description="
// + errorDescription
// + ", error_uri="
// + errorUri
// + "]";
// }
// return "AccessToken [access_token=" + accessToken + ", token_type=" + tokenType + "]";
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(accessToken, tokenType, error, errorDescription, errorUri);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final AccessToken other = (AccessToken) obj;
// return Objects.equals(this.accessToken, other.accessToken)
// && Objects.equals(this.raw, other.raw)
// && Objects.equals(this.tokenType, other.tokenType);
// }
//
// public boolean isError() {
// return !Strings.isNullOrEmpty(error);
// }
//
// public String getRaw() {
// return raw;
// }
//
// public void setRaw(String raw) {
// this.raw = raw;
// }
//
// public OAuthToken toOAuthToken() {
// return new OAuthToken(accessToken, null, getRaw());
// }
// }
| import com.google.gerrit.common.Nullable;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.github.oauth.OAuthProtocol.AccessToken;
import java.io.IOException;
import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | public static final String EXTERNAL_ID_PREFIX =
ExternalId.SCHEME_EXTERNAL + ":" + OAuthWebFilter.GITHUB_EXT_ID;
private final Provider<IdentifiedUser> userProvider;
private final GitHubOAuthConfig config;
private final AccountCache accountCache;
private final GitHubHttpConnector httpConnector;
@Inject
public IdentifiedUserGitHubLoginProvider(
Provider<IdentifiedUser> identifiedUserProvider,
GitHubOAuthConfig config,
GitHubHttpConnector httpConnector,
AccountCache accountCache) {
this.userProvider = identifiedUserProvider;
this.config = config;
this.accountCache = accountCache;
this.httpConnector = httpConnector;
}
@Override
public GitHubLogin get() {
IdentifiedUser currentUser = userProvider.get();
return get(currentUser.getUserName().get());
}
@Override
@Nullable
public GitHubLogin get(String username) {
try { | // Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthProtocol.java
// public static class AccessToken {
// public String accessToken;
// public String tokenType;
// public String error;
// public String errorDescription;
// public String errorUri;
// public String raw;
//
// public AccessToken() {}
//
// public AccessToken(String token) {
// this(token, "");
// }
//
// public AccessToken(String token, String type) {
// this();
// this.accessToken = token;
// this.tokenType = type;
// }
//
// @Override
// public String toString() {
// if (isError()) {
// return "Error AccessToken [error="
// + error
// + ", error_description="
// + errorDescription
// + ", error_uri="
// + errorUri
// + "]";
// }
// return "AccessToken [access_token=" + accessToken + ", token_type=" + tokenType + "]";
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(accessToken, tokenType, error, errorDescription, errorUri);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final AccessToken other = (AccessToken) obj;
// return Objects.equals(this.accessToken, other.accessToken)
// && Objects.equals(this.raw, other.raw)
// && Objects.equals(this.tokenType, other.tokenType);
// }
//
// public boolean isError() {
// return !Strings.isNullOrEmpty(error);
// }
//
// public String getRaw() {
// return raw;
// }
//
// public void setRaw(String raw) {
// this.raw = raw;
// }
//
// public OAuthToken toOAuthToken() {
// return new OAuthToken(accessToken, null, getRaw());
// }
// }
// Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/IdentifiedUserGitHubLoginProvider.java
import com.google.gerrit.common.Nullable;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.github.oauth.OAuthProtocol.AccessToken;
import java.io.IOException;
import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public static final String EXTERNAL_ID_PREFIX =
ExternalId.SCHEME_EXTERNAL + ":" + OAuthWebFilter.GITHUB_EXT_ID;
private final Provider<IdentifiedUser> userProvider;
private final GitHubOAuthConfig config;
private final AccountCache accountCache;
private final GitHubHttpConnector httpConnector;
@Inject
public IdentifiedUserGitHubLoginProvider(
Provider<IdentifiedUser> identifiedUserProvider,
GitHubOAuthConfig config,
GitHubHttpConnector httpConnector,
AccountCache accountCache) {
this.userProvider = identifiedUserProvider;
this.config = config;
this.accountCache = accountCache;
this.httpConnector = httpConnector;
}
@Override
public GitHubLogin get() {
IdentifiedUser currentUser = userProvider.get();
return get(currentUser.getUserName().get());
}
@Override
@Nullable
public GitHubLogin get(String username) {
try { | AccessToken accessToken = newAccessTokenFromUser(username); |
GerritCodeReview/plugins_github | github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthFilter.java | // Path: github-oauth/src/main/java/com/google/gerrit/httpd/XGerritAuth.java
// @Singleton
// public class XGerritAuth {
// public static final String X_GERRIT_AUTH = "X-Gerrit-Auth";
// private WebSessionManager manager;
//
// @Inject
// public XGerritAuth(
// WebSessionManagerFactory managerFactory,
// @Named(WebSessionManager.CACHE_NAME) Cache<String, Val> cache) {
// this.manager = managerFactory.create(cache);
// }
//
// public String getAuthValue(Cookie gerritCookie) {
// Val session = manager.get(new WebSessionManager.Key(gerritCookie.getValue()));
// return session.getAuth();
// }
// }
| import org.slf4j.LoggerFactory;
import com.google.common.collect.Sets;
import com.google.gerrit.httpd.GitOverHttpServlet;
import com.google.gerrit.httpd.XGerritAuth;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import java.io.IOException;
import java.util.Set;
import java.util.regex.Pattern;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils; | webFilter.init(filterConfig);
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String requestUrl = httpRequest.getRequestURI();
if (!config.enabled || skipOAuth(httpRequest)) {
chain.doFilter(request, response);
} else {
if (GIT_HTTP_REQUEST_PATTERN.matcher(requestUrl).matches()) {
chain.doFilter(request, response);
} else {
webFilter.doFilter(request, response, chain);
}
}
}
public static boolean skipOAuth(HttpServletRequest httpRequest) {
return isStaticResource(httpRequest)
|| isRpcCall(httpRequest)
|| isAuthenticatedRestCall(httpRequest)
|| isAllowed(httpRequest);
}
private static boolean isAuthenticatedRestCall(HttpServletRequest httpRequest) { | // Path: github-oauth/src/main/java/com/google/gerrit/httpd/XGerritAuth.java
// @Singleton
// public class XGerritAuth {
// public static final String X_GERRIT_AUTH = "X-Gerrit-Auth";
// private WebSessionManager manager;
//
// @Inject
// public XGerritAuth(
// WebSessionManagerFactory managerFactory,
// @Named(WebSessionManager.CACHE_NAME) Cache<String, Val> cache) {
// this.manager = managerFactory.create(cache);
// }
//
// public String getAuthValue(Cookie gerritCookie) {
// Val session = manager.get(new WebSessionManager.Key(gerritCookie.getValue()));
// return session.getAuth();
// }
// }
// Path: github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthFilter.java
import org.slf4j.LoggerFactory;
import com.google.common.collect.Sets;
import com.google.gerrit.httpd.GitOverHttpServlet;
import com.google.gerrit.httpd.XGerritAuth;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import java.io.IOException;
import java.util.Set;
import java.util.regex.Pattern;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
webFilter.init(filterConfig);
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String requestUrl = httpRequest.getRequestURI();
if (!config.enabled || skipOAuth(httpRequest)) {
chain.doFilter(request, response);
} else {
if (GIT_HTTP_REQUEST_PATTERN.matcher(requestUrl).matches()) {
chain.doFilter(request, response);
} else {
webFilter.doFilter(request, response, chain);
}
}
}
public static boolean skipOAuth(HttpServletRequest httpRequest) {
return isStaticResource(httpRequest)
|| isRpcCall(httpRequest)
|| isAuthenticatedRestCall(httpRequest)
|| isAllowed(httpRequest);
}
private static boolean isAuthenticatedRestCall(HttpServletRequest httpRequest) { | return !StringUtils.isEmpty(httpRequest.getHeader(XGerritAuth.X_GERRIT_AUTH)); |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/JobStatusController.java | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java
// public class BatchImporter {
//
// private final ConcurrentHashMap<Integer, GitJob> jobs = new ConcurrentHashMap<>();
// private final JobExecutor executor;
// protected final IdentifiedUser user;
//
// public BatchImporter(final JobExecutor executor, final IdentifiedUser user) {
// this.executor = executor;
// this.user = user;
// }
//
// public Collection<GitJob> getJobs() {
// return jobs.values();
// }
//
// public void reset() {
// cancel();
// jobs.clear();
// }
//
// public void cancel() {
// for (GitJob job : jobs.values()) {
// job.cancel();
// }
// }
//
// public synchronized void schedule(int idx, GitJob pullRequestImportJob) {
// jobs.put(new Integer(idx), pullRequestImportJob);
// executor.exec(pullRequestImportJob);
// }
// }
//
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJobStatus.java
// public class GitJobStatus {
//
// public enum Code {
// SYNC,
// COMPLETE,
// FAILED,
// CANCELLED;
//
// @Override
// public String toString() {
// return name().toLowerCase();
// }
// }
//
// public final int index;
// private Code status;
// private String shortDescription;
// private String value;
//
// public GitJobStatus(int index) {
// this.index = index;
// this.status = GitJobStatus.Code.SYNC;
// this.shortDescription = "Init";
// this.value = "Initializing ...";
// }
//
// public void update(Code code, String sDescription, String description) {
// this.status = code;
// this.shortDescription = sDescription;
// this.value = description;
// }
//
// public Code getStatus() {
// return status;
// }
//
// public String getShortDescription() {
// return shortDescription;
// }
//
// public String getValue() {
// return value;
// }
//
// public void update(Code statusCode) {
// this.status = statusCode;
// this.shortDescription = statusCode.name();
// this.value = statusCode.name();
// }
//
// public void printJson(PrintWriter out) throws IOException {
// try (JsonWriter writer = new JsonWriter(out)) {
// new Gson().toJson(this, GitJobStatus.class, writer);
// }
// }
// }
| import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;
import com.googlesource.gerrit.plugins.github.git.BatchImporter;
import com.googlesource.gerrit.plugins.github.git.GitJob;
import com.googlesource.gerrit.plugins.github.git.GitJobStatus;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import javax.servlet.http.HttpServletResponse; | // Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.wizard;
public class JobStatusController {
public JobStatusController() {
super();
}
| // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java
// public class BatchImporter {
//
// private final ConcurrentHashMap<Integer, GitJob> jobs = new ConcurrentHashMap<>();
// private final JobExecutor executor;
// protected final IdentifiedUser user;
//
// public BatchImporter(final JobExecutor executor, final IdentifiedUser user) {
// this.executor = executor;
// this.user = user;
// }
//
// public Collection<GitJob> getJobs() {
// return jobs.values();
// }
//
// public void reset() {
// cancel();
// jobs.clear();
// }
//
// public void cancel() {
// for (GitJob job : jobs.values()) {
// job.cancel();
// }
// }
//
// public synchronized void schedule(int idx, GitJob pullRequestImportJob) {
// jobs.put(new Integer(idx), pullRequestImportJob);
// executor.exec(pullRequestImportJob);
// }
// }
//
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJobStatus.java
// public class GitJobStatus {
//
// public enum Code {
// SYNC,
// COMPLETE,
// FAILED,
// CANCELLED;
//
// @Override
// public String toString() {
// return name().toLowerCase();
// }
// }
//
// public final int index;
// private Code status;
// private String shortDescription;
// private String value;
//
// public GitJobStatus(int index) {
// this.index = index;
// this.status = GitJobStatus.Code.SYNC;
// this.shortDescription = "Init";
// this.value = "Initializing ...";
// }
//
// public void update(Code code, String sDescription, String description) {
// this.status = code;
// this.shortDescription = sDescription;
// this.value = description;
// }
//
// public Code getStatus() {
// return status;
// }
//
// public String getShortDescription() {
// return shortDescription;
// }
//
// public String getValue() {
// return value;
// }
//
// public void update(Code statusCode) {
// this.status = statusCode;
// this.shortDescription = statusCode.name();
// this.value = statusCode.name();
// }
//
// public void printJson(PrintWriter out) throws IOException {
// try (JsonWriter writer = new JsonWriter(out)) {
// new Gson().toJson(this, GitJobStatus.class, writer);
// }
// }
// }
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/JobStatusController.java
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;
import com.googlesource.gerrit.plugins.github.git.BatchImporter;
import com.googlesource.gerrit.plugins.github.git.GitJob;
import com.googlesource.gerrit.plugins.github.git.GitJobStatus;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.wizard;
public class JobStatusController {
public JobStatusController() {
super();
}
| protected void respondWithJobStatusJson(HttpServletResponse resp, BatchImporter cloner) |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/JobStatusController.java | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java
// public class BatchImporter {
//
// private final ConcurrentHashMap<Integer, GitJob> jobs = new ConcurrentHashMap<>();
// private final JobExecutor executor;
// protected final IdentifiedUser user;
//
// public BatchImporter(final JobExecutor executor, final IdentifiedUser user) {
// this.executor = executor;
// this.user = user;
// }
//
// public Collection<GitJob> getJobs() {
// return jobs.values();
// }
//
// public void reset() {
// cancel();
// jobs.clear();
// }
//
// public void cancel() {
// for (GitJob job : jobs.values()) {
// job.cancel();
// }
// }
//
// public synchronized void schedule(int idx, GitJob pullRequestImportJob) {
// jobs.put(new Integer(idx), pullRequestImportJob);
// executor.exec(pullRequestImportJob);
// }
// }
//
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJobStatus.java
// public class GitJobStatus {
//
// public enum Code {
// SYNC,
// COMPLETE,
// FAILED,
// CANCELLED;
//
// @Override
// public String toString() {
// return name().toLowerCase();
// }
// }
//
// public final int index;
// private Code status;
// private String shortDescription;
// private String value;
//
// public GitJobStatus(int index) {
// this.index = index;
// this.status = GitJobStatus.Code.SYNC;
// this.shortDescription = "Init";
// this.value = "Initializing ...";
// }
//
// public void update(Code code, String sDescription, String description) {
// this.status = code;
// this.shortDescription = sDescription;
// this.value = description;
// }
//
// public Code getStatus() {
// return status;
// }
//
// public String getShortDescription() {
// return shortDescription;
// }
//
// public String getValue() {
// return value;
// }
//
// public void update(Code statusCode) {
// this.status = statusCode;
// this.shortDescription = statusCode.name();
// this.value = statusCode.name();
// }
//
// public void printJson(PrintWriter out) throws IOException {
// try (JsonWriter writer = new JsonWriter(out)) {
// new Gson().toJson(this, GitJobStatus.class, writer);
// }
// }
// }
| import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;
import com.googlesource.gerrit.plugins.github.git.BatchImporter;
import com.googlesource.gerrit.plugins.github.git.GitJob;
import com.googlesource.gerrit.plugins.github.git.GitJobStatus;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import javax.servlet.http.HttpServletResponse; | // Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.wizard;
public class JobStatusController {
public JobStatusController() {
super();
}
protected void respondWithJobStatusJson(HttpServletResponse resp, BatchImporter cloner)
throws IOException {
Collection<GitJob> jobs = cloner.getJobs(); | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java
// public class BatchImporter {
//
// private final ConcurrentHashMap<Integer, GitJob> jobs = new ConcurrentHashMap<>();
// private final JobExecutor executor;
// protected final IdentifiedUser user;
//
// public BatchImporter(final JobExecutor executor, final IdentifiedUser user) {
// this.executor = executor;
// this.user = user;
// }
//
// public Collection<GitJob> getJobs() {
// return jobs.values();
// }
//
// public void reset() {
// cancel();
// jobs.clear();
// }
//
// public void cancel() {
// for (GitJob job : jobs.values()) {
// job.cancel();
// }
// }
//
// public synchronized void schedule(int idx, GitJob pullRequestImportJob) {
// jobs.put(new Integer(idx), pullRequestImportJob);
// executor.exec(pullRequestImportJob);
// }
// }
//
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJobStatus.java
// public class GitJobStatus {
//
// public enum Code {
// SYNC,
// COMPLETE,
// FAILED,
// CANCELLED;
//
// @Override
// public String toString() {
// return name().toLowerCase();
// }
// }
//
// public final int index;
// private Code status;
// private String shortDescription;
// private String value;
//
// public GitJobStatus(int index) {
// this.index = index;
// this.status = GitJobStatus.Code.SYNC;
// this.shortDescription = "Init";
// this.value = "Initializing ...";
// }
//
// public void update(Code code, String sDescription, String description) {
// this.status = code;
// this.shortDescription = sDescription;
// this.value = description;
// }
//
// public Code getStatus() {
// return status;
// }
//
// public String getShortDescription() {
// return shortDescription;
// }
//
// public String getValue() {
// return value;
// }
//
// public void update(Code statusCode) {
// this.status = statusCode;
// this.shortDescription = statusCode.name();
// this.value = statusCode.name();
// }
//
// public void printJson(PrintWriter out) throws IOException {
// try (JsonWriter writer = new JsonWriter(out)) {
// new Gson().toJson(this, GitJobStatus.class, writer);
// }
// }
// }
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/JobStatusController.java
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;
import com.googlesource.gerrit.plugins.github.git.BatchImporter;
import com.googlesource.gerrit.plugins.github.git.GitJob;
import com.googlesource.gerrit.plugins.github.git.GitJobStatus;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.wizard;
public class JobStatusController {
public JobStatusController() {
super();
}
protected void respondWithJobStatusJson(HttpServletResponse resp, BatchImporter cloner)
throws IOException {
Collection<GitJob> jobs = cloner.getJobs(); | List<GitJobStatus> jobListStatus = Lists.newArrayList(); |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ErrorJob.java | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJobStatus.java
// public enum Code {
// SYNC,
// COMPLETE,
// FAILED,
// CANCELLED;
//
// @Override
// public String toString() {
// return name().toLowerCase();
// }
// }
| import com.googlesource.gerrit.plugins.github.git.GitJobStatus.Code; | // Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.git;
public class ErrorJob extends AbstractCloneJob implements GitJob {
private int idx;
private String organisation;
private String repository;
private Throwable exception;
private GitJobStatus status;
public ErrorJob(int idx, String organisation, String repository, Throwable e) {
this.idx = idx;
this.organisation = organisation;
this.repository = repository;
this.exception = e;
status = new GitJobStatus(idx); | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitJobStatus.java
// public enum Code {
// SYNC,
// COMPLETE,
// FAILED,
// CANCELLED;
//
// @Override
// public String toString() {
// return name().toLowerCase();
// }
// }
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ErrorJob.java
import com.googlesource.gerrit.plugins.github.git.GitJobStatus.Code;
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.git;
public class ErrorJob extends AbstractCloneJob implements GitJob {
private int idx;
private String organisation;
private String repository;
private Throwable exception;
private GitJobStatus status;
public ErrorJob(int idx, String organisation, String repository, Throwable e) {
this.idx = idx;
this.organisation = organisation;
this.repository = repository;
this.exception = e;
status = new GitJobStatus(idx); | status.update(Code.FAILED, "Failed", getErrorDescription(exception)); |
GerritCodeReview/plugins_github | github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImporter.java
// @SessionScoped
// public class PullRequestImporter extends BatchImporter {
// private static final Logger log = LoggerFactory.getLogger(PullRequestImporter.class);
//
// private final PullRequestImportJob.Factory prImportJobProvider;
//
// @Inject
// public PullRequestImporter(
// JobExecutor executor, IdentifiedUser user, PullRequestImportJob.Factory prImportJobProvider) {
// super(executor, user);
// this.prImportJobProvider = prImportJobProvider;
// }
//
// public void importPullRequest(
// int idx,
// String organisation,
// String repoName,
// int pullRequestId,
// PullRequestImportType importType) {
// try {
// PullRequestImportJob pullRequestImportJob =
// prImportJobProvider.create(idx, organisation, repoName, pullRequestId, importType);
// log.debug("New Pull request import job created: " + pullRequestImportJob);
// schedule(idx, pullRequestImportJob);
// } catch (Throwable e) {
// schedule(idx, new ErrorJob(idx, organisation, repoName, e));
// }
// }
// }
| import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.github.git.PullRequestImportType;
import com.googlesource.gerrit.plugins.github.git.PullRequestImporter;
import java.io.IOException;
import org.kohsuke.github.GHEventPayload.PullRequest;
import org.kohsuke.github.GHRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | // Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.notification;
/**
* Handles pull_request event in github webhook.
*
* @see <a href= "https://developer.github.com/v3/activity/events/types/#pullrequestevent"> Pull
* Request Event</a>
*/
@Singleton
class PullRequestHandler implements WebhookEventHandler<PullRequest> {
private static final Logger logger = LoggerFactory.getLogger(PullRequestHandler.class); | // Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImporter.java
// @SessionScoped
// public class PullRequestImporter extends BatchImporter {
// private static final Logger log = LoggerFactory.getLogger(PullRequestImporter.class);
//
// private final PullRequestImportJob.Factory prImportJobProvider;
//
// @Inject
// public PullRequestImporter(
// JobExecutor executor, IdentifiedUser user, PullRequestImportJob.Factory prImportJobProvider) {
// super(executor, user);
// this.prImportJobProvider = prImportJobProvider;
// }
//
// public void importPullRequest(
// int idx,
// String organisation,
// String repoName,
// int pullRequestId,
// PullRequestImportType importType) {
// try {
// PullRequestImportJob pullRequestImportJob =
// prImportJobProvider.create(idx, organisation, repoName, pullRequestId, importType);
// log.debug("New Pull request import job created: " + pullRequestImportJob);
// schedule(idx, pullRequestImportJob);
// } catch (Throwable e) {
// schedule(idx, new ErrorJob(idx, organisation, repoName, e));
// }
// }
// }
// Path: github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.github.git.PullRequestImportType;
import com.googlesource.gerrit.plugins.github.git.PullRequestImporter;
import java.io.IOException;
import org.kohsuke.github.GHEventPayload.PullRequest;
import org.kohsuke.github.GHRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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.
package com.googlesource.gerrit.plugins.github.notification;
/**
* Handles pull_request event in github webhook.
*
* @see <a href= "https://developer.github.com/v3/activity/events/types/#pullrequestevent"> Pull
* Request Event</a>
*/
@Singleton
class PullRequestHandler implements WebhookEventHandler<PullRequest> {
private static final Logger logger = LoggerFactory.getLogger(PullRequestHandler.class); | private final Provider<PullRequestImporter> prImportProvider; |
arnaudroger/mapping-benchmark | jpa-hibernate/src/main/java/org/simpleflatmapper/HibernateBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.param.LimitParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | package org.simpleflatmapper;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class HibernateBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
// Path: jpa-hibernate/src/main/java/org/simpleflatmapper/HibernateBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.param.LimitParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package org.simpleflatmapper;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class HibernateBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception { | ConnectionParam connParam = new ConnectionParam(); |
arnaudroger/mapping-benchmark | jpa-hibernate/src/main/java/org/simpleflatmapper/HibernateBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.param.LimitParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | package org.simpleflatmapper;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class HibernateBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception {
ConnectionParam connParam = new ConnectionParam();
connParam.db = db;
connParam.init();
sf = Persistence.createEntityManagerFactory("jpa");
}
@Benchmark
public void _04Fields(LimitParam limit, final Blackhole blackhole) throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
// Path: jpa-hibernate/src/main/java/org/simpleflatmapper/HibernateBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.param.LimitParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package org.simpleflatmapper;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class HibernateBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception {
ConnectionParam connParam = new ConnectionParam();
connParam.db = db;
connParam.init();
sf = Persistence.createEntityManagerFactory("jpa");
}
@Benchmark
public void _04Fields(LimitParam limit, final Blackhole blackhole) throws Exception { | JPATester.select4Fields(sf, limit, blackhole); |
arnaudroger/mapping-benchmark | spring/src/main/java/org/simpleflatmapper/spring/RowMapperSfmBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.spring.JdbcTemplateMapperFactory;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet; | package org.simpleflatmapper.spring;
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
RowMapperBeanPropertyBenchmark._04Fields H2 1000 thrpt 20 380.087 ± 24.794 ops/s
RowMapperBeanPropertyBenchmark._16Fields H2 1000 thrpt 20 80.582 ± 3.645 ops/s
RowMapperSfmBenchmark._04Fields H2 1000 thrpt 20 3515.758 ± 152.728 ops/s
RowMapperSfmBenchmark._16Fields H2 1000 thrpt 20 1019.907 ± 48.610 ops/s
*/
@State(Scope.Benchmark)
public class RowMapperSfmBenchmark { | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: spring/src/main/java/org/simpleflatmapper/spring/RowMapperSfmBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.spring.JdbcTemplateMapperFactory;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
package org.simpleflatmapper.spring;
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
RowMapperBeanPropertyBenchmark._04Fields H2 1000 thrpt 20 380.087 ± 24.794 ops/s
RowMapperBeanPropertyBenchmark._16Fields H2 1000 thrpt 20 80.582 ± 3.645 ops/s
RowMapperSfmBenchmark._04Fields H2 1000 thrpt 20 3515.758 ± 152.728 ops/s
RowMapperSfmBenchmark._16Fields H2 1000 thrpt 20 1019.907 ± 48.610 ops/s
*/
@State(Scope.Benchmark)
public class RowMapperSfmBenchmark { | private RowMapper<MappedObject4> mapper4; |
arnaudroger/mapping-benchmark | spring/src/main/java/org/simpleflatmapper/spring/RowMapperSfmBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.spring.JdbcTemplateMapperFactory;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet; | package org.simpleflatmapper.spring;
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
RowMapperBeanPropertyBenchmark._04Fields H2 1000 thrpt 20 380.087 ± 24.794 ops/s
RowMapperBeanPropertyBenchmark._16Fields H2 1000 thrpt 20 80.582 ± 3.645 ops/s
RowMapperSfmBenchmark._04Fields H2 1000 thrpt 20 3515.758 ± 152.728 ops/s
RowMapperSfmBenchmark._16Fields H2 1000 thrpt 20 1019.907 ± 48.610 ops/s
*/
@State(Scope.Benchmark)
public class RowMapperSfmBenchmark {
private RowMapper<MappedObject4> mapper4;
private RowMapper<MappedObject16> mapper16;
@Setup
public void init() {
mapper4 = JdbcTemplateMapperFactory.newInstance().newRowMapper(MappedObject4.class);
mapper16 = JdbcTemplateMapperFactory.newInstance().newRowMapper(MappedObject16.class);
}
@Benchmark | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: spring/src/main/java/org/simpleflatmapper/spring/RowMapperSfmBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.spring.JdbcTemplateMapperFactory;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
package org.simpleflatmapper.spring;
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
RowMapperBeanPropertyBenchmark._04Fields H2 1000 thrpt 20 380.087 ± 24.794 ops/s
RowMapperBeanPropertyBenchmark._16Fields H2 1000 thrpt 20 80.582 ± 3.645 ops/s
RowMapperSfmBenchmark._04Fields H2 1000 thrpt 20 3515.758 ± 152.728 ops/s
RowMapperSfmBenchmark._16Fields H2 1000 thrpt 20 1019.907 ± 48.610 ops/s
*/
@State(Scope.Benchmark)
public class RowMapperSfmBenchmark {
private RowMapper<MappedObject4> mapper4;
private RowMapper<MappedObject16> mapper16;
@Setup
public void init() {
mapper4 = JdbcTemplateMapperFactory.newInstance().newRowMapper(MappedObject4.class);
mapper16 = JdbcTemplateMapperFactory.newInstance().newRowMapper(MappedObject16.class);
}
@Benchmark | public void _04Fields(ConnectionParam connectionHolder, LimitParam limit, final Blackhole blackhole) throws Exception { |
arnaudroger/mapping-benchmark | jpa-batoo/src/main/java/org/simpleflatmapper/batoo/BatooBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.jpa.beans.MappedObject16;
import org.simpleflatmapper.param.LimitParam; | package org.simpleflatmapper.batoo;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class BatooBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
// Path: jpa-batoo/src/main/java/org/simpleflatmapper/batoo/BatooBenchmark.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.jpa.beans.MappedObject16;
import org.simpleflatmapper.param.LimitParam;
package org.simpleflatmapper.batoo;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class BatooBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception { | ConnectionParam connParam = new ConnectionParam(); |
arnaudroger/mapping-benchmark | jpa-batoo/src/main/java/org/simpleflatmapper/batoo/BatooBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.jpa.beans.MappedObject16;
import org.simpleflatmapper.param.LimitParam; | package org.simpleflatmapper.batoo;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class BatooBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception {
ConnectionParam connParam = new ConnectionParam();
connParam.db = db;
connParam.init();
sf = Persistence.createEntityManagerFactory("jpa");
}
@Benchmark
public void _04Fields(LimitParam limit, final Blackhole blackhole) throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
// Path: jpa-batoo/src/main/java/org/simpleflatmapper/batoo/BatooBenchmark.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.jpa.beans.MappedObject16;
import org.simpleflatmapper.param.LimitParam;
package org.simpleflatmapper.batoo;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class BatooBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception {
ConnectionParam connParam = new ConnectionParam();
connParam.db = db;
connParam.init();
sf = Persistence.createEntityManagerFactory("jpa");
}
@Benchmark
public void _04Fields(LimitParam limit, final Blackhole blackhole) throws Exception { | JPATester.select4Fields(sf, limit, blackhole); |
arnaudroger/mapping-benchmark | sfm-datastax/src/main/java/org/simpleflatmapper/datastax/DatastaxHelper.java | // Path: sfm-datastax/src/main/java/org/simpleflatmapper/beans/Object4Fields.java
// @Table(keyspace = "testsfm", name = "test_table")
// public class Object4Fields {
// @PartitionKey
// private long id;
//
// @Column(name = "year_started")
// private int yearStarted;
// private String name;
// private String email;
//
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
//
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
//
// @Override
// public String toString() {
// return "Object4Fields{" +
// "id=" + id +
// ", yearStarted=" + yearStarted +
// ", name='" + name + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
| import com.datastax.driver.core.*;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.thrift.transport.TTransportException;
import org.simpleflatmapper.datastax.DatastaxMapper;
import org.simpleflatmapper.datastax.DatastaxMapperFactory;
import org.simpleflatmapper.beans.Object4Fields;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays; | package org.simpleflatmapper.datastax;
/**
* Created by aroger on 19/10/2015.
*/
public class DatastaxHelper {
public static final int NB_ROWS = 10000;
Cluster cluster;
Session session;
| // Path: sfm-datastax/src/main/java/org/simpleflatmapper/beans/Object4Fields.java
// @Table(keyspace = "testsfm", name = "test_table")
// public class Object4Fields {
// @PartitionKey
// private long id;
//
// @Column(name = "year_started")
// private int yearStarted;
// private String name;
// private String email;
//
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
//
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
//
// @Override
// public String toString() {
// return "Object4Fields{" +
// "id=" + id +
// ", yearStarted=" + yearStarted +
// ", name='" + name + '\'' +
// ", email='" + email + '\'' +
// '}';
// }
// }
// Path: sfm-datastax/src/main/java/org/simpleflatmapper/datastax/DatastaxHelper.java
import com.datastax.driver.core.*;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.thrift.transport.TTransportException;
import org.simpleflatmapper.datastax.DatastaxMapper;
import org.simpleflatmapper.datastax.DatastaxMapperFactory;
import org.simpleflatmapper.beans.Object4Fields;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays;
package org.simpleflatmapper.datastax;
/**
* Created by aroger on 19/10/2015.
*/
public class DatastaxHelper {
public static final int NB_ROWS = 10000;
Cluster cluster;
Session session;
| Mapper<Object4Fields> datastaxMapper; |
arnaudroger/mapping-benchmark | sql2o/src/main/java/org/simpleflatmapper/sql2o/Sql2OBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
import org.sql2o.ResultSetIterable;
import org.sql2o.Sql2o; | package org.simpleflatmapper.sql2o;
@State(Scope.Benchmark)
public class Sql2OBenchmark {
| // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sql2o/src/main/java/org/simpleflatmapper/sql2o/Sql2OBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
import org.sql2o.ResultSetIterable;
import org.sql2o.Sql2o;
package org.simpleflatmapper.sql2o;
@State(Scope.Benchmark)
public class Sql2OBenchmark {
| public static final String SELECT_OBJECT4 = MappedObject4.SELECT_WITH_LIMIT.replace("?", ":limit"); |
arnaudroger/mapping-benchmark | sql2o/src/main/java/org/simpleflatmapper/sql2o/Sql2OBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
import org.sql2o.ResultSetIterable;
import org.sql2o.Sql2o; | package org.simpleflatmapper.sql2o;
@State(Scope.Benchmark)
public class Sql2OBenchmark {
public static final String SELECT_OBJECT4 = MappedObject4.SELECT_WITH_LIMIT.replace("?", ":limit");
public static final String SELECT_OBJECT16 = MappedObject16.SELECT_WITH_LIMIT.replace("?", ":limit");
private Sql2o sql2o;
@Param(value="MOCK")
DbTarget db;
public Sql2OBenchmark() {
}
@Setup
public void init() throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sql2o/src/main/java/org/simpleflatmapper/sql2o/Sql2OBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
import org.sql2o.ResultSetIterable;
import org.sql2o.Sql2o;
package org.simpleflatmapper.sql2o;
@State(Scope.Benchmark)
public class Sql2OBenchmark {
public static final String SELECT_OBJECT4 = MappedObject4.SELECT_WITH_LIMIT.replace("?", ":limit");
public static final String SELECT_OBJECT16 = MappedObject16.SELECT_WITH_LIMIT.replace("?", ":limit");
private Sql2o sql2o;
@Param(value="MOCK")
DbTarget db;
public Sql2OBenchmark() {
}
@Setup
public void init() throws Exception { | ConnectionParam connParam = new ConnectionParam(); |
arnaudroger/mapping-benchmark | sfm-jdbc/src/main/java/org/simpleflatmapper/jdbc/JdbcManualBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.db.RowMapper;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet; | @Override
public MappedObject16 map(ResultSet rs) throws Exception {
MappedObject16 o = new MappedObject16();
o.setId(rs.getLong(1));
o.setName(rs.getString(2));
o.setEmail(rs.getString(3));
o.setYearStarted(rs.getInt(4));
o.setField5(rs.getShort(5));
o.setField6(rs.getInt(6));
o.setField7(rs.getLong(7));
o.setField8(rs.getFloat(8));
o.setField9(rs.getDouble(9));
o.setField10(rs.getShort(10));
o.setField11(rs.getInt(11));
o.setField12(rs.getLong(12));
o.setField13(rs.getFloat(13));
o.setField14(rs.getDouble(14));
o.setField14(rs.getDouble(14));
o.setField15(rs.getInt(15));
o.setField16(rs.getInt(16));
return o;
}
};
}
@SuppressWarnings("JpaQueryApiInspection")
@Benchmark | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sfm-jdbc/src/main/java/org/simpleflatmapper/jdbc/JdbcManualBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.db.RowMapper;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet;
@Override
public MappedObject16 map(ResultSet rs) throws Exception {
MappedObject16 o = new MappedObject16();
o.setId(rs.getLong(1));
o.setName(rs.getString(2));
o.setEmail(rs.getString(3));
o.setYearStarted(rs.getInt(4));
o.setField5(rs.getShort(5));
o.setField6(rs.getInt(6));
o.setField7(rs.getLong(7));
o.setField8(rs.getFloat(8));
o.setField9(rs.getDouble(9));
o.setField10(rs.getShort(10));
o.setField11(rs.getInt(11));
o.setField12(rs.getLong(12));
o.setField13(rs.getFloat(13));
o.setField14(rs.getDouble(14));
o.setField14(rs.getDouble(14));
o.setField15(rs.getInt(15));
o.setField16(rs.getInt(16));
return o;
}
};
}
@SuppressWarnings("JpaQueryApiInspection")
@Benchmark | public void _04Fields(ConnectionParam connectionHolder, LimitParam limit, final Blackhole blackhole) throws Exception { |
arnaudroger/mapping-benchmark | jpa-eclipselink/src/main/java/org/simpleflatmapper/eclipselink/EclipseLinkBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.param.LimitParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.List; | package org.simpleflatmapper.eclipselink;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class EclipseLinkBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
// Path: jpa-eclipselink/src/main/java/org/simpleflatmapper/eclipselink/EclipseLinkBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.param.LimitParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.List;
package org.simpleflatmapper.eclipselink;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class EclipseLinkBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception { | ConnectionParam connParam = new ConnectionParam(); |
arnaudroger/mapping-benchmark | jpa-eclipselink/src/main/java/org/simpleflatmapper/eclipselink/EclipseLinkBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.param.LimitParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.List; | package org.simpleflatmapper.eclipselink;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class EclipseLinkBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception {
ConnectionParam connParam = new ConnectionParam();
connParam.db = db;
connParam.init();
sf = Persistence.createEntityManagerFactory("jpa");
}
@Benchmark
public void _04Fields(LimitParam limit, final Blackhole blackhole) throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
//
// Path: common-jpa/src/main/java/org/simpleflatmapper/jpa/beans/JPATester.java
// public class JPATester {
//
//
// public static void select4Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject4 s");
// }
//
// public static void select16Fields(EntityManagerFactory entityManagerFactory, LimitParam limitParam, Blackhole blackhole) {
// select(entityManagerFactory, limitParam, blackhole, "select s from MappedObject16 s");
// }
//
// public static void select(EntityManagerFactory entityManagerFactory, LimitParam limit, Blackhole blackhole, String strQuery) {
// EntityManager entityManager = entityManagerFactory.createEntityManager();
// try {
// Query query = entityManager.createQuery(strQuery);
// query.setMaxResults(limit.limit);
// List<?> sr = query.getResultList();
// for (Object o : sr) {
// blackhole.consume(o);
// }
// } finally {
// entityManager.close();
// }
// }
// }
// Path: jpa-eclipselink/src/main/java/org/simpleflatmapper/eclipselink/EclipseLinkBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.jpa.beans.JPATester;
import org.simpleflatmapper.param.LimitParam;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.List;
package org.simpleflatmapper.eclipselink;
@State(Scope.Benchmark)
/**
* batoo has a dependency on a old library of asm.
* batoo benchmark cannot run at the sane time as sfm asm.
* needs to exclude asm from the pom to run batoo.
*
*
*/
/*
Benchmark (db) (limit) Mode Cnt Score Error Units
BatooBenchmark._04Fields H2 1 thrpt 20 424105.769 ± 7998.794 ops/s
BatooBenchmark._04Fields H2 10 thrpt 20 184095.607 ± 2349.584 ops/s
BatooBenchmark._04Fields H2 100 thrpt 20 26205.799 ± 371.146 ops/s
BatooBenchmark._04Fields H2 1000 thrpt 20 2667.718 ± 56.348 ops/s
BatooBenchmark._16Fields H2 1 thrpt 20 172638.194 ± 3858.660 ops/s
BatooBenchmark._16Fields H2 10 thrpt 20 64638.056 ± 4692.277 ops/s
BatooBenchmark._16Fields H2 100 thrpt 20 8910.878 ± 731.142 ops/s
BatooBenchmark._16Fields H2 1000 thrpt 20 916.999 ± 40.375 ops/s
*/
public class EclipseLinkBenchmark {
private EntityManagerFactory sf;
@Param(value="H2")
DbTarget db;
@Setup
public void init() throws Exception {
ConnectionParam connParam = new ConnectionParam();
connParam.db = db;
connParam.init();
sf = Persistence.createEntityManagerFactory("jpa");
}
@Benchmark
public void _04Fields(LimitParam limit, final Blackhole blackhole) throws Exception { | JPATester.select4Fields(sf, limit, blackhole); |
arnaudroger/mapping-benchmark | sql2o/src/main/java/org/simpleflatmapper/sql2o/Sql2OSfmBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.sql2o.SfmResultSetHandlerFactoryBuilder;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
import org.sql2o.ResultSetHandlerFactory;
import org.sql2o.ResultSetIterable;
import org.sql2o.Sql2o;
import javax.naming.NamingException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map; | package org.simpleflatmapper.sql2o;
@State(Scope.Benchmark)
public class Sql2OSfmBenchmark {
| // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sql2o/src/main/java/org/simpleflatmapper/sql2o/Sql2OSfmBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.sql2o.SfmResultSetHandlerFactoryBuilder;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
import org.sql2o.ResultSetHandlerFactory;
import org.sql2o.ResultSetIterable;
import org.sql2o.Sql2o;
import javax.naming.NamingException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
package org.simpleflatmapper.sql2o;
@State(Scope.Benchmark)
public class Sql2OSfmBenchmark {
| private final ResultSetHandlerFactory<MappedObject4> factory4; |
arnaudroger/mapping-benchmark | sql2o/src/main/java/org/simpleflatmapper/sql2o/Sql2OSfmBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.sql2o.SfmResultSetHandlerFactoryBuilder;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
import org.sql2o.ResultSetHandlerFactory;
import org.sql2o.ResultSetIterable;
import org.sql2o.Sql2o;
import javax.naming.NamingException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map; | package org.simpleflatmapper.sql2o;
@State(Scope.Benchmark)
public class Sql2OSfmBenchmark {
private final ResultSetHandlerFactory<MappedObject4> factory4;
private final ResultSetHandlerFactory<MappedObject16> factory16;
private Sql2o sql2o;
@Param(value="MOCK")
DbTarget db;
public Sql2OSfmBenchmark() {
Map<String, String> columnMappings = new HashMap<>();
columnMappings.put("YEAR_STARTED", "yearStarted");
SfmResultSetHandlerFactoryBuilder builder = new SfmResultSetHandlerFactoryBuilder();
builder.setColumnMappings(columnMappings);
factory4 = builder.newFactory(MappedObject4.class);
factory16 = builder.newFactory(MappedObject16.class);
}
@Setup
public void init() throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sql2o/src/main/java/org/simpleflatmapper/sql2o/Sql2OSfmBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.sql2o.SfmResultSetHandlerFactoryBuilder;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
import org.sql2o.ResultSetHandlerFactory;
import org.sql2o.ResultSetIterable;
import org.sql2o.Sql2o;
import javax.naming.NamingException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
package org.simpleflatmapper.sql2o;
@State(Scope.Benchmark)
public class Sql2OSfmBenchmark {
private final ResultSetHandlerFactory<MappedObject4> factory4;
private final ResultSetHandlerFactory<MappedObject16> factory16;
private Sql2o sql2o;
@Param(value="MOCK")
DbTarget db;
public Sql2OSfmBenchmark() {
Map<String, String> columnMappings = new HashMap<>();
columnMappings.put("YEAR_STARTED", "yearStarted");
SfmResultSetHandlerFactoryBuilder builder = new SfmResultSetHandlerFactoryBuilder();
builder.setColumnMappings(columnMappings);
factory4 = builder.newFactory(MappedObject4.class);
factory16 = builder.newFactory(MappedObject16.class);
}
@Setup
public void init() throws Exception { | ConnectionParam connParam = new ConnectionParam(); |
arnaudroger/mapping-benchmark | spring/src/main/java/org/simpleflatmapper/spring/RowMapperBeanPropertyBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet; | package org.simpleflatmapper.spring;
@State(Scope.Benchmark)
public class RowMapperBeanPropertyBenchmark { | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: spring/src/main/java/org/simpleflatmapper/spring/RowMapperBeanPropertyBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
package org.simpleflatmapper.spring;
@State(Scope.Benchmark)
public class RowMapperBeanPropertyBenchmark { | private RowMapper<MappedObject4> mapper4; |
arnaudroger/mapping-benchmark | spring/src/main/java/org/simpleflatmapper/spring/RowMapperBeanPropertyBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet; | package org.simpleflatmapper.spring;
@State(Scope.Benchmark)
public class RowMapperBeanPropertyBenchmark {
private RowMapper<MappedObject4> mapper4;
private RowMapper<MappedObject16> mapper16;
@Setup
public void init() {
mapper4 = new BeanPropertyRowMapper<>(MappedObject4.class);
mapper16 = new BeanPropertyRowMapper<>(MappedObject16.class);
}
@Benchmark | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: spring/src/main/java/org/simpleflatmapper/spring/RowMapperBeanPropertyBenchmark.java
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
package org.simpleflatmapper.spring;
@State(Scope.Benchmark)
public class RowMapperBeanPropertyBenchmark {
private RowMapper<MappedObject4> mapper4;
private RowMapper<MappedObject16> mapper16;
@Setup
public void init() {
mapper4 = new BeanPropertyRowMapper<>(MappedObject4.class);
mapper16 = new BeanPropertyRowMapper<>(MappedObject16.class);
}
@Benchmark | public void _04Fields(ConnectionParam connectionHolder, LimitParam limit, final Blackhole blackhole) throws Exception { |
arnaudroger/mapping-benchmark | jooq/src/main/java/org/simpleflatmapper/beans/tables/records/TestSmallBenchmarkObjectRecord.java | // Path: jooq/src/main/java/org/simpleflatmapper/beans/tables/TestSmallBenchmarkObject.java
// @Generated(
// value = {
// "http://www.jooq.org",
// "jOOQ version:3.7.0"
// },
// comments = "This class is generated by jOOQ"
// )
// @SuppressWarnings({ "all", "unchecked", "rawtypes" })
// public class TestSmallBenchmarkObject extends TableImpl<TestSmallBenchmarkObjectRecord> {
//
// private static final long serialVersionUID = 1741374422;
//
// /**
// * The reference instance of <code>sfm.test_small_benchmark_object</code>
// */
// public static final TestSmallBenchmarkObject TEST_SMALL_BENCHMARK_OBJECT = new TestSmallBenchmarkObject();
//
// /**
// * The class holding records for this type
// */
// @Override
// public Class<TestSmallBenchmarkObjectRecord> getRecordType() {
// return TestSmallBenchmarkObjectRecord.class;
// }
//
// /**
// * The column <code>sfm.test_small_benchmark_object.id</code>.
// */
// public final TableField<TestSmallBenchmarkObjectRecord, Long> ID = createField("ID", org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "");
//
// /**
// * The column <code>sfm.test_small_benchmark_object.name</code>.
// */
// public final TableField<TestSmallBenchmarkObjectRecord, String> NAME = createField("NAME", org.jooq.impl.SQLDataType.VARCHAR.length(100), this, "");
//
// /**
// * The column <code>sfm.test_small_benchmark_object.email</code>.
// */
// public final TableField<TestSmallBenchmarkObjectRecord, String> EMAIL = createField("EMAIL", org.jooq.impl.SQLDataType.VARCHAR.length(100), this, "");
//
// /**
// * The column <code>sfm.test_small_benchmark_object.year_started</code>.
// */
// public final TableField<TestSmallBenchmarkObjectRecord, Integer> YEAR_STARTED = createField("YEAR_STARTED", org.jooq.impl.SQLDataType.INTEGER, this, "");
//
// /**
// * Create a <code>sfm.test_small_benchmark_object</code> table reference
// */
// public TestSmallBenchmarkObject() {
// this("TEST_SMALL_BENCHMARK_OBJECT", null);
// }
//
// /**
// * Create an aliased <code>sfm.test_small_benchmark_object</code> table reference
// */
// public TestSmallBenchmarkObject(String alias) {
// this(alias, TEST_SMALL_BENCHMARK_OBJECT);
// }
//
// private TestSmallBenchmarkObject(String alias, Table<TestSmallBenchmarkObjectRecord> aliased) {
// this(alias, aliased, null);
// }
//
// private TestSmallBenchmarkObject(String alias, Table<TestSmallBenchmarkObjectRecord> aliased, Field<?>[] parameters) {
// super(alias, null, aliased, parameters, "");
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public UniqueKey<TestSmallBenchmarkObjectRecord> getPrimaryKey() {
// return Keys.KEY_TEST_SMALL_BENCHMARK_OBJECT_PRIMARY;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public List<UniqueKey<TestSmallBenchmarkObjectRecord>> getKeys() {
// return Arrays.<UniqueKey<TestSmallBenchmarkObjectRecord>>asList(Keys.KEY_TEST_SMALL_BENCHMARK_OBJECT_PRIMARY);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public TestSmallBenchmarkObject as(String alias) {
// return new TestSmallBenchmarkObject(alias, this);
// }
//
// /**
// * Rename this table
// */
// public TestSmallBenchmarkObject rename(String name) {
// return new TestSmallBenchmarkObject(name, null);
// }
// }
| import javax.annotation.Generated;
import org.jooq.Field;
import org.jooq.Record1;
import org.jooq.Record4;
import org.jooq.Row4;
import org.jooq.impl.UpdatableRecordImpl;
import org.simpleflatmapper.beans.tables.TestSmallBenchmarkObject; | @Override
public Record1<Long> key() {
return (Record1) super.key();
}
// -------------------------------------------------------------------------
// Record4 type implementation
// -------------------------------------------------------------------------
/**
* {@inheritDoc}
*/
@Override
public Row4<Long, String, String, Integer> fieldsRow() {
return (Row4) super.fieldsRow();
}
/**
* {@inheritDoc}
*/
@Override
public Row4<Long, String, String, Integer> valuesRow() {
return (Row4) super.valuesRow();
}
/**
* {@inheritDoc}
*/
@Override
public Field<Long> field1() { | // Path: jooq/src/main/java/org/simpleflatmapper/beans/tables/TestSmallBenchmarkObject.java
// @Generated(
// value = {
// "http://www.jooq.org",
// "jOOQ version:3.7.0"
// },
// comments = "This class is generated by jOOQ"
// )
// @SuppressWarnings({ "all", "unchecked", "rawtypes" })
// public class TestSmallBenchmarkObject extends TableImpl<TestSmallBenchmarkObjectRecord> {
//
// private static final long serialVersionUID = 1741374422;
//
// /**
// * The reference instance of <code>sfm.test_small_benchmark_object</code>
// */
// public static final TestSmallBenchmarkObject TEST_SMALL_BENCHMARK_OBJECT = new TestSmallBenchmarkObject();
//
// /**
// * The class holding records for this type
// */
// @Override
// public Class<TestSmallBenchmarkObjectRecord> getRecordType() {
// return TestSmallBenchmarkObjectRecord.class;
// }
//
// /**
// * The column <code>sfm.test_small_benchmark_object.id</code>.
// */
// public final TableField<TestSmallBenchmarkObjectRecord, Long> ID = createField("ID", org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "");
//
// /**
// * The column <code>sfm.test_small_benchmark_object.name</code>.
// */
// public final TableField<TestSmallBenchmarkObjectRecord, String> NAME = createField("NAME", org.jooq.impl.SQLDataType.VARCHAR.length(100), this, "");
//
// /**
// * The column <code>sfm.test_small_benchmark_object.email</code>.
// */
// public final TableField<TestSmallBenchmarkObjectRecord, String> EMAIL = createField("EMAIL", org.jooq.impl.SQLDataType.VARCHAR.length(100), this, "");
//
// /**
// * The column <code>sfm.test_small_benchmark_object.year_started</code>.
// */
// public final TableField<TestSmallBenchmarkObjectRecord, Integer> YEAR_STARTED = createField("YEAR_STARTED", org.jooq.impl.SQLDataType.INTEGER, this, "");
//
// /**
// * Create a <code>sfm.test_small_benchmark_object</code> table reference
// */
// public TestSmallBenchmarkObject() {
// this("TEST_SMALL_BENCHMARK_OBJECT", null);
// }
//
// /**
// * Create an aliased <code>sfm.test_small_benchmark_object</code> table reference
// */
// public TestSmallBenchmarkObject(String alias) {
// this(alias, TEST_SMALL_BENCHMARK_OBJECT);
// }
//
// private TestSmallBenchmarkObject(String alias, Table<TestSmallBenchmarkObjectRecord> aliased) {
// this(alias, aliased, null);
// }
//
// private TestSmallBenchmarkObject(String alias, Table<TestSmallBenchmarkObjectRecord> aliased, Field<?>[] parameters) {
// super(alias, null, aliased, parameters, "");
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public UniqueKey<TestSmallBenchmarkObjectRecord> getPrimaryKey() {
// return Keys.KEY_TEST_SMALL_BENCHMARK_OBJECT_PRIMARY;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public List<UniqueKey<TestSmallBenchmarkObjectRecord>> getKeys() {
// return Arrays.<UniqueKey<TestSmallBenchmarkObjectRecord>>asList(Keys.KEY_TEST_SMALL_BENCHMARK_OBJECT_PRIMARY);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public TestSmallBenchmarkObject as(String alias) {
// return new TestSmallBenchmarkObject(alias, this);
// }
//
// /**
// * Rename this table
// */
// public TestSmallBenchmarkObject rename(String name) {
// return new TestSmallBenchmarkObject(name, null);
// }
// }
// Path: jooq/src/main/java/org/simpleflatmapper/beans/tables/records/TestSmallBenchmarkObjectRecord.java
import javax.annotation.Generated;
import org.jooq.Field;
import org.jooq.Record1;
import org.jooq.Record4;
import org.jooq.Row4;
import org.jooq.impl.UpdatableRecordImpl;
import org.simpleflatmapper.beans.tables.TestSmallBenchmarkObject;
@Override
public Record1<Long> key() {
return (Record1) super.key();
}
// -------------------------------------------------------------------------
// Record4 type implementation
// -------------------------------------------------------------------------
/**
* {@inheritDoc}
*/
@Override
public Row4<Long, String, String, Integer> fieldsRow() {
return (Row4) super.fieldsRow();
}
/**
* {@inheritDoc}
*/
@Override
public Row4<Long, String, String, Integer> valuesRow() {
return (Row4) super.valuesRow();
}
/**
* {@inheritDoc}
*/
@Override
public Field<Long> field1() { | return TestSmallBenchmarkObject.TEST_SMALL_BENCHMARK_OBJECT.ID; |
arnaudroger/mapping-benchmark | mybatis/src/main/java/org/simpleflatmapper/mybatis/DbObjectMapper.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
| import org.apache.ibatis.annotations.Select;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import java.util.List; | package org.simpleflatmapper.mybatis;
public interface DbObjectMapper {
String SELECT_4_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT #{limit}";
String SELECT_16_WITH_LIMIT = "SELECT * FROM TEST_BENCHMARK_OBJECT_16 LIMIT #{limit}";
@Select(SELECT_4_WITH_LIMIT) | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
// Path: mybatis/src/main/java/org/simpleflatmapper/mybatis/DbObjectMapper.java
import org.apache.ibatis.annotations.Select;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import java.util.List;
package org.simpleflatmapper.mybatis;
public interface DbObjectMapper {
String SELECT_4_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT #{limit}";
String SELECT_16_WITH_LIMIT = "SELECT * FROM TEST_BENCHMARK_OBJECT_16 LIMIT #{limit}";
@Select(SELECT_4_WITH_LIMIT) | List<MappedObject4> select4Fields(int limit); |
arnaudroger/mapping-benchmark | sfm-csv/src/main/java/org/simpleflatmapper/UnivocityCsvParserBenchmark.java | // Path: sfm-csv/src/main/java/org/simpleflatmapper/param/CsvParam.java
// @State(Scope.Benchmark)
// public class CsvParam {
//
// @Param(value={"false", "true"})
// public boolean parallel;
// @Param(value={"false", "true"})
// public boolean quotes;
//
// @Param(value={"8192"})
// public int parallelBuffersize = 64;
//
// @Param(value={"1", "10","1000","100000","-1"})
// public int nbRows = 10;
//
// public ExecutorService executorService;
//
// public static final String url = "worldcitiespop.txt.gz";
//
// public static final String fileName = getFileDirectory() + File.separator + "worldcitiespop.txt";
//
// private static String getFileDirectory() {
// return System.getProperty("csv.dir", System.getProperty("java.io.tmpdir"));
// }
//
// public static final String fileNameQuotes = getFileDirectory() + File.separator + "worldcitiespop2.txt";
//
//
// @Setup
// public void setUp() {
// executorService = Executors.newSingleThreadExecutor(new ThreadFactory() {
// @Override
// public Thread newThread(Runnable r) {
// return new Thread(r);
// }
// });
// }
//
// @TearDown
// public void tearDown() {
// executorService.shutdown();
// }
//
// public Reader getReader() throws IOException {
// Reader reader = getSingleThreadedReader(quotes, nbRows);
//
// if (parallel) {
// reader = new ParallelReader(reader, executorService, parallelBuffersize * 1024, 8092);//, i -> { Thread.yield(); return i; });
// }
//
// return reader;
// }
//
// public static Reader getSingleThreadedReader(boolean quotes, int nbRows) throws IOException {
// Reader reader;
// if (quotes) {
// reader = _getReaderQuotes(nbRows);
// } else {
// reader = _getReader(nbRows);
// }
// return reader;
// }
//
// private static Reader _getReader(int nbRows) throws IOException {
// File file = getFileName(nbRows, CsvParam.fileName);
// if (!file.exists()) {
// rewriteFile(nbRows, file, CsvParam::getRewriter);
// }
// return newReader(file);
// }
//
// private static File getFileName(int nbRows, String f) {
// return new File(nbRows == -1 ? f : appendNbRow(f, nbRows));
// }
//
// private static Reader _getReaderQuotes(int nbRows) throws IOException {
// File file = getFileName(nbRows, fileNameQuotes);
// if (!file.exists()) {
// rewriteFile(nbRows, file, CsvParam::getQuotesRewriter);
// }
// return newReader(file);
// }
//
// private static String appendNbRow(String fileNameQuotes, int nbRows) {
// int i = fileNameQuotes.lastIndexOf('.');
// return fileNameQuotes.substring(0, i) + "-" + nbRows + fileNameQuotes.substring(i);
// }
//
// private static void rewriteFile(int nbRows, File file, Function<Writer, CheckedConsumer<String[]>> rewriterFunction) throws IOException {
// try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
// Writer writer = new OutputStreamWriter(bos)) {
// CheckedConsumer<String[]> rewriter = rewriterFunction.apply(writer);
// try (
// BufferedInputStream bis = new BufferedInputStream(new GZIPInputStream(CsvParam.class.getClassLoader().getResourceAsStream(url)))
//
// ) {
//
// CsvParser.DSL dsl = CsvParser.dsl();
// CsvReader reader = dsl.reader(new InputStreamReader(bis));
//
// if (nbRows == -1) {
// reader.read(rewriter);
// } else {
// reader.read(rewriter, nbRows);
// }
// }
// }
// }
//
// private static CheckedConsumer<String[]> getQuotesRewriter(Writer writer) {
// return (row) -> {
// for (int i = 0; i < row.length; i++) {
// String cell = row[i];
// if (i > 0) {
// writer.write(",");
// }
// writer.write("\"");
//
// for (int j = 0; j < cell.length(); j++) {
// char c = cell.charAt(j);
// if (c == '"') {
// writer.append('"');
// }
// writer.append(c);
// }
// writer.write("\"");
// }
// writer.write("\n");
// };
// }
//
// private static CheckedConsumer<String[]> getRewriter(Writer writer) {
// return (row) -> {
// for (int i = 0; i < row.length; i++) {
// String cell = row[i];
// if (i > 0) {
// writer.write(",");
// }
// writer.write(cell);
// }
// writer.write("\n");
// };
// }
//
// private static Reader newReader(File file) throws IOException {
// return Channels.newReader(FileChannel.open(file.toPath()), UTF_8.newDecoder(), -1);
// }
//
// }
| import com.univocity.parsers.common.ParsingContext;
import com.univocity.parsers.common.processor.AbstractRowProcessor;
import com.univocity.parsers.common.processor.BeanProcessor;
import com.univocity.parsers.csv.CsvParserSettings;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.param.CsvParam;
import java.io.IOException;
import java.io.Reader; | package org.simpleflatmapper;
@BenchmarkMode(Mode.AverageTime)
public class UnivocityCsvParserBenchmark {
@Benchmark | // Path: sfm-csv/src/main/java/org/simpleflatmapper/param/CsvParam.java
// @State(Scope.Benchmark)
// public class CsvParam {
//
// @Param(value={"false", "true"})
// public boolean parallel;
// @Param(value={"false", "true"})
// public boolean quotes;
//
// @Param(value={"8192"})
// public int parallelBuffersize = 64;
//
// @Param(value={"1", "10","1000","100000","-1"})
// public int nbRows = 10;
//
// public ExecutorService executorService;
//
// public static final String url = "worldcitiespop.txt.gz";
//
// public static final String fileName = getFileDirectory() + File.separator + "worldcitiespop.txt";
//
// private static String getFileDirectory() {
// return System.getProperty("csv.dir", System.getProperty("java.io.tmpdir"));
// }
//
// public static final String fileNameQuotes = getFileDirectory() + File.separator + "worldcitiespop2.txt";
//
//
// @Setup
// public void setUp() {
// executorService = Executors.newSingleThreadExecutor(new ThreadFactory() {
// @Override
// public Thread newThread(Runnable r) {
// return new Thread(r);
// }
// });
// }
//
// @TearDown
// public void tearDown() {
// executorService.shutdown();
// }
//
// public Reader getReader() throws IOException {
// Reader reader = getSingleThreadedReader(quotes, nbRows);
//
// if (parallel) {
// reader = new ParallelReader(reader, executorService, parallelBuffersize * 1024, 8092);//, i -> { Thread.yield(); return i; });
// }
//
// return reader;
// }
//
// public static Reader getSingleThreadedReader(boolean quotes, int nbRows) throws IOException {
// Reader reader;
// if (quotes) {
// reader = _getReaderQuotes(nbRows);
// } else {
// reader = _getReader(nbRows);
// }
// return reader;
// }
//
// private static Reader _getReader(int nbRows) throws IOException {
// File file = getFileName(nbRows, CsvParam.fileName);
// if (!file.exists()) {
// rewriteFile(nbRows, file, CsvParam::getRewriter);
// }
// return newReader(file);
// }
//
// private static File getFileName(int nbRows, String f) {
// return new File(nbRows == -1 ? f : appendNbRow(f, nbRows));
// }
//
// private static Reader _getReaderQuotes(int nbRows) throws IOException {
// File file = getFileName(nbRows, fileNameQuotes);
// if (!file.exists()) {
// rewriteFile(nbRows, file, CsvParam::getQuotesRewriter);
// }
// return newReader(file);
// }
//
// private static String appendNbRow(String fileNameQuotes, int nbRows) {
// int i = fileNameQuotes.lastIndexOf('.');
// return fileNameQuotes.substring(0, i) + "-" + nbRows + fileNameQuotes.substring(i);
// }
//
// private static void rewriteFile(int nbRows, File file, Function<Writer, CheckedConsumer<String[]>> rewriterFunction) throws IOException {
// try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
// Writer writer = new OutputStreamWriter(bos)) {
// CheckedConsumer<String[]> rewriter = rewriterFunction.apply(writer);
// try (
// BufferedInputStream bis = new BufferedInputStream(new GZIPInputStream(CsvParam.class.getClassLoader().getResourceAsStream(url)))
//
// ) {
//
// CsvParser.DSL dsl = CsvParser.dsl();
// CsvReader reader = dsl.reader(new InputStreamReader(bis));
//
// if (nbRows == -1) {
// reader.read(rewriter);
// } else {
// reader.read(rewriter, nbRows);
// }
// }
// }
// }
//
// private static CheckedConsumer<String[]> getQuotesRewriter(Writer writer) {
// return (row) -> {
// for (int i = 0; i < row.length; i++) {
// String cell = row[i];
// if (i > 0) {
// writer.write(",");
// }
// writer.write("\"");
//
// for (int j = 0; j < cell.length(); j++) {
// char c = cell.charAt(j);
// if (c == '"') {
// writer.append('"');
// }
// writer.append(c);
// }
// writer.write("\"");
// }
// writer.write("\n");
// };
// }
//
// private static CheckedConsumer<String[]> getRewriter(Writer writer) {
// return (row) -> {
// for (int i = 0; i < row.length; i++) {
// String cell = row[i];
// if (i > 0) {
// writer.write(",");
// }
// writer.write(cell);
// }
// writer.write("\n");
// };
// }
//
// private static Reader newReader(File file) throws IOException {
// return Channels.newReader(FileChannel.open(file.toPath()), UTF_8.newDecoder(), -1);
// }
//
// }
// Path: sfm-csv/src/main/java/org/simpleflatmapper/UnivocityCsvParserBenchmark.java
import com.univocity.parsers.common.ParsingContext;
import com.univocity.parsers.common.processor.AbstractRowProcessor;
import com.univocity.parsers.common.processor.BeanProcessor;
import com.univocity.parsers.csv.CsvParserSettings;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.param.CsvParam;
import java.io.IOException;
import java.io.Reader;
package org.simpleflatmapper;
@BenchmarkMode(Mode.AverageTime)
public class UnivocityCsvParserBenchmark {
@Benchmark | public void mapCsv(Blackhole blackhole, CsvParam csvParam) throws IOException { |
arnaudroger/mapping-benchmark | sfm-jdbc/src/main/java/org/simpleflatmapper/sfm/JdbcSfmDynamicBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.JdbcMapper;
import org.simpleflatmapper.jdbc.JdbcMapperFactory;
import org.simpleflatmapper.util.CheckedConsumer;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet; | package org.simpleflatmapper.sfm;
@State(Scope.Benchmark)
public class JdbcSfmDynamicBenchmark {
| // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sfm-jdbc/src/main/java/org/simpleflatmapper/sfm/JdbcSfmDynamicBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.JdbcMapper;
import org.simpleflatmapper.jdbc.JdbcMapperFactory;
import org.simpleflatmapper.util.CheckedConsumer;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet;
package org.simpleflatmapper.sfm;
@State(Scope.Benchmark)
public class JdbcSfmDynamicBenchmark {
| private JdbcMapper<MappedObject4> mapper4; |
arnaudroger/mapping-benchmark | sfm-jdbc/src/main/java/org/simpleflatmapper/sfm/JdbcSfmDynamicBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.JdbcMapper;
import org.simpleflatmapper.jdbc.JdbcMapperFactory;
import org.simpleflatmapper.util.CheckedConsumer;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet; | package org.simpleflatmapper.sfm;
@State(Scope.Benchmark)
public class JdbcSfmDynamicBenchmark {
private JdbcMapper<MappedObject4> mapper4;
private JdbcMapper<MappedObject16> mapper16;
@Setup
public void init() {
mapper4 = JdbcMapperFactory.newInstance().newMapper(MappedObject4.class);
mapper16 = JdbcMapperFactory.newInstance().newMapper(MappedObject16.class);
}
@Benchmark | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sfm-jdbc/src/main/java/org/simpleflatmapper/sfm/JdbcSfmDynamicBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.JdbcMapper;
import org.simpleflatmapper.jdbc.JdbcMapperFactory;
import org.simpleflatmapper.util.CheckedConsumer;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet;
package org.simpleflatmapper.sfm;
@State(Scope.Benchmark)
public class JdbcSfmDynamicBenchmark {
private JdbcMapper<MappedObject4> mapper4;
private JdbcMapper<MappedObject16> mapper16;
@Setup
public void init() {
mapper4 = JdbcMapperFactory.newInstance().newMapper(MappedObject4.class);
mapper16 = JdbcMapperFactory.newInstance().newMapper(MappedObject16.class);
}
@Benchmark | public void _04Fields(ConnectionParam connectionParam, LimitParam limitParam, final Blackhole blackhole) throws Exception { |
arnaudroger/mapping-benchmark | mybatis/src/main/java/org/simpleflatmapper/mybatis/MyBatisBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam; | package org.simpleflatmapper.mybatis;
@State(Scope.Benchmark)
public class MyBatisBenchmark {
private SqlSessionFactory sqlSessionFactory;
@Param(value="MOCK")
DbTarget db;
@Setup
public void init() throws Exception { | // Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: mybatis/src/main/java/org/simpleflatmapper/mybatis/MyBatisBenchmark.java
import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.DbTarget;
import org.simpleflatmapper.param.LimitParam;
package org.simpleflatmapper.mybatis;
@State(Scope.Benchmark)
public class MyBatisBenchmark {
private SqlSessionFactory sqlSessionFactory;
@Param(value="MOCK")
DbTarget db;
@Setup
public void init() throws Exception { | ConnectionParam connParam = new ConnectionParam(); |
arnaudroger/mapping-benchmark | sfm-jdbc/src/main/java/org/simpleflatmapper/sfm/JdbcSfmStaticBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.JdbcMapper;
import org.simpleflatmapper.jdbc.JdbcMapperFactory;
import org.simpleflatmapper.util.CheckedConsumer;
import org.simpleflatmapper.util.RowHandler;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet; | package org.simpleflatmapper.sfm;
@State(Scope.Benchmark)
public class JdbcSfmStaticBenchmark {
| // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sfm-jdbc/src/main/java/org/simpleflatmapper/sfm/JdbcSfmStaticBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.JdbcMapper;
import org.simpleflatmapper.jdbc.JdbcMapperFactory;
import org.simpleflatmapper.util.CheckedConsumer;
import org.simpleflatmapper.util.RowHandler;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet;
package org.simpleflatmapper.sfm;
@State(Scope.Benchmark)
public class JdbcSfmStaticBenchmark {
| private JdbcMapper<MappedObject4> mapper4; |
arnaudroger/mapping-benchmark | sfm-jdbc/src/main/java/org/simpleflatmapper/sfm/JdbcSfmStaticBenchmark.java | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
| import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.JdbcMapper;
import org.simpleflatmapper.jdbc.JdbcMapperFactory;
import org.simpleflatmapper.util.CheckedConsumer;
import org.simpleflatmapper.util.RowHandler;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet; |
@Setup
public void init() {
mapper4 = JdbcMapperFactory.newInstance().newBuilder(MappedObject4.class)
.addMapping("id")
.addMapping("name")
.addMapping("email")
.addMapping("year_started").mapper();
mapper16 = JdbcMapperFactory.newInstance().newBuilder(MappedObject16.class)
.addMapping("id")
.addMapping("name")
.addMapping("email")
.addMapping("year_started")
.addMapping("field5")
.addMapping("field6")
.addMapping("field7")
.addMapping("field8")
.addMapping("field9")
.addMapping("field10")
.addMapping("field11")
.addMapping("field12")
.addMapping("field13")
.addMapping("field14")
.addMapping("field15")
.addMapping("field16")
.mapper();
}
@Benchmark | // Path: common-db/src/main/java/org/simpleflatmapper/beans/MappedObject4.java
// public class MappedObject4 {
// public static final String SELECT_WITH_LIMIT = "SELECT * FROM TEST_SMALL_BENCHMARK_OBJECT LIMIT ?";
//
// private long id;
//
// private int yearStarted;
// private String name;
// private String email;
// public long getId() {
// return id;
// }
// public void setId(long id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public String getEmail() {
// return email;
// }
// public void setEmail(String email) {
// this.email = email;
// }
// public int getYearStarted() {
// return yearStarted;
// }
// public void setYearStarted(int yearStarted) {
// this.yearStarted = yearStarted;
// }
// @Override
// public String toString() {
// return "MappedObject4 [id=" + id + ", yearStarted="
// + yearStarted + ", name=" + name + ", email=" + email + "]";
// }
//
//
// }
//
// Path: common-db/src/main/java/org/simpleflatmapper/db/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// @Param(value="H2")
// public DbTarget db;
//
// public DataSource dataSource;
//
// public Connection connection;
//
// @Setup
// public void init() throws SQLException, NamingException {
// dataSource = ConnectionHelper.getDataSource(db);
//
// if (db != DbTarget.MOCK) {
// Connection conn = dataSource.getConnection();
// try {
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.SMALL);
// ConnectionHelper.createTableAndInsertData(conn, ConnectionHelper.Table.BIG);
// } finally {
// conn.close();
// }
// }
// connection = dataSource.getConnection();
//
// // Create initial context
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// InitialContextFactory.class.getName());
// InitialContext ic = new InitialContext();
//
// ic.bind("java:datasource", dataSource);
//
// }
//
// public Connection getConnection() throws SQLException {
// return dataSource.getConnection();
// }
//
// public void executeStatement(String statement, ResultSetHandler handler, Object... params) throws Exception {
// PreparedStatement prepareStatement = connection.prepareStatement(statement);
// try {
// setParams(prepareStatement, params);
// ResultSet rs = prepareStatement.executeQuery();
// try {
// handler.handle(rs);
// }finally {
// rs.close();
// }
// } finally {
// prepareStatement.close();
// }
// }
//
// public void setParams(PreparedStatement prepareStatement, Object[] params) throws SQLException {
// if (params != null) {
// for(int i = 0; i < params.length; i++) {
// prepareStatement.setObject(i + 1, params[i]);
// }
// }
// }
// }
// Path: sfm-jdbc/src/main/java/org/simpleflatmapper/sfm/JdbcSfmStaticBenchmark.java
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.jdbc.JdbcMapper;
import org.simpleflatmapper.jdbc.JdbcMapperFactory;
import org.simpleflatmapper.util.CheckedConsumer;
import org.simpleflatmapper.util.RowHandler;
import org.simpleflatmapper.beans.MappedObject16;
import org.simpleflatmapper.beans.MappedObject4;
import org.simpleflatmapper.db.ConnectionParam;
import org.simpleflatmapper.db.ResultSetHandler;
import org.simpleflatmapper.param.LimitParam;
import java.sql.ResultSet;
@Setup
public void init() {
mapper4 = JdbcMapperFactory.newInstance().newBuilder(MappedObject4.class)
.addMapping("id")
.addMapping("name")
.addMapping("email")
.addMapping("year_started").mapper();
mapper16 = JdbcMapperFactory.newInstance().newBuilder(MappedObject16.class)
.addMapping("id")
.addMapping("name")
.addMapping("email")
.addMapping("year_started")
.addMapping("field5")
.addMapping("field6")
.addMapping("field7")
.addMapping("field8")
.addMapping("field9")
.addMapping("field10")
.addMapping("field11")
.addMapping("field12")
.addMapping("field13")
.addMapping("field14")
.addMapping("field15")
.addMapping("field16")
.mapper();
}
@Benchmark | public void _04Fields(ConnectionParam connectionParam, LimitParam limitParam, final Blackhole blackhole) throws Exception { |
mpusher/mpush-client-java | src/test/java/com/mpush/client/MPushClientTest.java | // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/ClientListener.java
// public interface ClientListener {
//
// void onConnected(Client client);
//
// void onDisConnected(Client client);
//
// void onHandshakeOk(Client client, int heartbeat);
//
// void onReceivePush(Client client, byte[] content, int messageId);
//
// void onKickUser(String deviceId, String userId);
//
// void onBind(boolean success, String userId);
//
// void onUnbind(boolean success, String userId);
// }
//
// Path: src/main/java/com/mpush/util/DefaultLogger.java
// public final class DefaultLogger implements Logger {
// private static final String TAG = "[mpush] ";
// private final DateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");
//
// private boolean enable = false;
//
// @Override
// public void enable(boolean enabled) {
// this.enable = enabled;
// }
//
// @Override
// public void d(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [D] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void i(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [I] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void w(String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [W] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void e(Throwable e, String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [E] " + TAG + s + '\n', args);
// e.printStackTrace();
// }
// }
//
// }
| import com.mpush.api.Client;
import com.mpush.api.ClientListener;
import com.mpush.util.DefaultLogger;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.client;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public class MPushClientTest {
private static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCghPCWCobG8nTD24juwSVataW7iViRxcTkey/B792VZEhuHjQvA3cAJgx2Lv8GnX8NIoShZtoCg3Cx6ecs+VEPD2fBcg2L4JK7xldGpOJ3ONEAyVsLOttXZtNXvyDZRijiErQALMTorcgi79M5uVX9/jMv2Ggb2XAeZhlLD28fHwIDAQAB";
private static final String allocServer = "http://103.60.220.145:9999/";
public static void main(String[] args) throws Exception {
int count = 1;
String serverHost = "127.0.0.1";
int sleep = 1000;
if (args != null && args.length > 0) {
count = Integer.parseInt(args[0]);
if (args.length > 1) {
serverHost = args[1];
}
if (args.length > 2) {
sleep = Integer.parseInt(args[1]);
}
}
ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); | // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/ClientListener.java
// public interface ClientListener {
//
// void onConnected(Client client);
//
// void onDisConnected(Client client);
//
// void onHandshakeOk(Client client, int heartbeat);
//
// void onReceivePush(Client client, byte[] content, int messageId);
//
// void onKickUser(String deviceId, String userId);
//
// void onBind(boolean success, String userId);
//
// void onUnbind(boolean success, String userId);
// }
//
// Path: src/main/java/com/mpush/util/DefaultLogger.java
// public final class DefaultLogger implements Logger {
// private static final String TAG = "[mpush] ";
// private final DateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");
//
// private boolean enable = false;
//
// @Override
// public void enable(boolean enabled) {
// this.enable = enabled;
// }
//
// @Override
// public void d(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [D] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void i(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [I] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void w(String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [W] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void e(Throwable e, String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [E] " + TAG + s + '\n', args);
// e.printStackTrace();
// }
// }
//
// }
// Path: src/test/java/com/mpush/client/MPushClientTest.java
import com.mpush.api.Client;
import com.mpush.api.ClientListener;
import com.mpush.util.DefaultLogger;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.client;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public class MPushClientTest {
private static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCghPCWCobG8nTD24juwSVataW7iViRxcTkey/B792VZEhuHjQvA3cAJgx2Lv8GnX8NIoShZtoCg3Cx6ecs+VEPD2fBcg2L4JK7xldGpOJ3ONEAyVsLOttXZtNXvyDZRijiErQALMTorcgi79M5uVX9/jMv2Ggb2XAeZhlLD28fHwIDAQAB";
private static final String allocServer = "http://103.60.220.145:9999/";
public static void main(String[] args) throws Exception {
int count = 1;
String serverHost = "127.0.0.1";
int sleep = 1000;
if (args != null && args.length > 0) {
count = Integer.parseInt(args[0]);
if (args.length > 1) {
serverHost = args[1];
}
if (args.length > 2) {
sleep = Integer.parseInt(args[1]);
}
}
ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); | ClientListener listener = new L(scheduledExecutor); |
mpusher/mpush-client-java | src/test/java/com/mpush/client/MPushClientTest.java | // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/ClientListener.java
// public interface ClientListener {
//
// void onConnected(Client client);
//
// void onDisConnected(Client client);
//
// void onHandshakeOk(Client client, int heartbeat);
//
// void onReceivePush(Client client, byte[] content, int messageId);
//
// void onKickUser(String deviceId, String userId);
//
// void onBind(boolean success, String userId);
//
// void onUnbind(boolean success, String userId);
// }
//
// Path: src/main/java/com/mpush/util/DefaultLogger.java
// public final class DefaultLogger implements Logger {
// private static final String TAG = "[mpush] ";
// private final DateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");
//
// private boolean enable = false;
//
// @Override
// public void enable(boolean enabled) {
// this.enable = enabled;
// }
//
// @Override
// public void d(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [D] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void i(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [I] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void w(String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [W] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void e(Throwable e, String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [E] " + TAG + s + '\n', args);
// e.printStackTrace();
// }
// }
//
// }
| import com.mpush.api.Client;
import com.mpush.api.ClientListener;
import com.mpush.util.DefaultLogger;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.client;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public class MPushClientTest {
private static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCghPCWCobG8nTD24juwSVataW7iViRxcTkey/B792VZEhuHjQvA3cAJgx2Lv8GnX8NIoShZtoCg3Cx6ecs+VEPD2fBcg2L4JK7xldGpOJ3ONEAyVsLOttXZtNXvyDZRijiErQALMTorcgi79M5uVX9/jMv2Ggb2XAeZhlLD28fHwIDAQAB";
private static final String allocServer = "http://103.60.220.145:9999/";
public static void main(String[] args) throws Exception {
int count = 1;
String serverHost = "127.0.0.1";
int sleep = 1000;
if (args != null && args.length > 0) {
count = Integer.parseInt(args[0]);
if (args.length > 1) {
serverHost = args[1];
}
if (args.length > 2) {
sleep = Integer.parseInt(args[1]);
}
}
ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
ClientListener listener = new L(scheduledExecutor); | // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/ClientListener.java
// public interface ClientListener {
//
// void onConnected(Client client);
//
// void onDisConnected(Client client);
//
// void onHandshakeOk(Client client, int heartbeat);
//
// void onReceivePush(Client client, byte[] content, int messageId);
//
// void onKickUser(String deviceId, String userId);
//
// void onBind(boolean success, String userId);
//
// void onUnbind(boolean success, String userId);
// }
//
// Path: src/main/java/com/mpush/util/DefaultLogger.java
// public final class DefaultLogger implements Logger {
// private static final String TAG = "[mpush] ";
// private final DateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");
//
// private boolean enable = false;
//
// @Override
// public void enable(boolean enabled) {
// this.enable = enabled;
// }
//
// @Override
// public void d(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [D] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void i(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [I] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void w(String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [W] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void e(Throwable e, String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [E] " + TAG + s + '\n', args);
// e.printStackTrace();
// }
// }
//
// }
// Path: src/test/java/com/mpush/client/MPushClientTest.java
import com.mpush.api.Client;
import com.mpush.api.ClientListener;
import com.mpush.util.DefaultLogger;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.client;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public class MPushClientTest {
private static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCghPCWCobG8nTD24juwSVataW7iViRxcTkey/B792VZEhuHjQvA3cAJgx2Lv8GnX8NIoShZtoCg3Cx6ecs+VEPD2fBcg2L4JK7xldGpOJ3ONEAyVsLOttXZtNXvyDZRijiErQALMTorcgi79M5uVX9/jMv2Ggb2XAeZhlLD28fHwIDAQAB";
private static final String allocServer = "http://103.60.220.145:9999/";
public static void main(String[] args) throws Exception {
int count = 1;
String serverHost = "127.0.0.1";
int sleep = 1000;
if (args != null && args.length > 0) {
count = Integer.parseInt(args[0]);
if (args.length > 1) {
serverHost = args[1];
}
if (args.length > 2) {
sleep = Integer.parseInt(args[1]);
}
}
ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
ClientListener listener = new L(scheduledExecutor); | Client client = null; |
mpusher/mpush-client-java | src/test/java/com/mpush/client/MPushClientTest.java | // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/ClientListener.java
// public interface ClientListener {
//
// void onConnected(Client client);
//
// void onDisConnected(Client client);
//
// void onHandshakeOk(Client client, int heartbeat);
//
// void onReceivePush(Client client, byte[] content, int messageId);
//
// void onKickUser(String deviceId, String userId);
//
// void onBind(boolean success, String userId);
//
// void onUnbind(boolean success, String userId);
// }
//
// Path: src/main/java/com/mpush/util/DefaultLogger.java
// public final class DefaultLogger implements Logger {
// private static final String TAG = "[mpush] ";
// private final DateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");
//
// private boolean enable = false;
//
// @Override
// public void enable(boolean enabled) {
// this.enable = enabled;
// }
//
// @Override
// public void d(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [D] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void i(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [I] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void w(String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [W] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void e(Throwable e, String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [E] " + TAG + s + '\n', args);
// e.printStackTrace();
// }
// }
//
// }
| import com.mpush.api.Client;
import com.mpush.api.ClientListener;
import com.mpush.util.DefaultLogger;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; | int sleep = 1000;
if (args != null && args.length > 0) {
count = Integer.parseInt(args[0]);
if (args.length > 1) {
serverHost = args[1];
}
if (args.length > 2) {
sleep = Integer.parseInt(args[1]);
}
}
ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
ClientListener listener = new L(scheduledExecutor);
Client client = null;
String cacheDir = MPushClientTest.class.getResource("/").getFile();
for (int i = 0; i < count; i++) {
client = ClientConfig
.build()
.setPublicKey(publicKey)
//.setAllotServer(allocServer)
.setServerHost(serverHost)
.setServerPort(3000)
.setDeviceId("deviceId-test" + i)
.setOsName("android")
.setOsVersion("6.0")
.setClientVersion("2.0")
.setUserId("user-" + i)
.setTags("tag-" + i)
.setSessionStorageDir(cacheDir + i) | // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/ClientListener.java
// public interface ClientListener {
//
// void onConnected(Client client);
//
// void onDisConnected(Client client);
//
// void onHandshakeOk(Client client, int heartbeat);
//
// void onReceivePush(Client client, byte[] content, int messageId);
//
// void onKickUser(String deviceId, String userId);
//
// void onBind(boolean success, String userId);
//
// void onUnbind(boolean success, String userId);
// }
//
// Path: src/main/java/com/mpush/util/DefaultLogger.java
// public final class DefaultLogger implements Logger {
// private static final String TAG = "[mpush] ";
// private final DateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");
//
// private boolean enable = false;
//
// @Override
// public void enable(boolean enabled) {
// this.enable = enabled;
// }
//
// @Override
// public void d(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [D] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void i(String s, Object... args) {
// if (enable) {
// System.out.printf(format.format(new Date()) + " [I] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void w(String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [W] " + TAG + s + '\n', args);
// }
// }
//
// @Override
// public void e(Throwable e, String s, Object... args) {
// if (enable) {
// System.err.printf(format.format(new Date()) + " [E] " + TAG + s + '\n', args);
// e.printStackTrace();
// }
// }
//
// }
// Path: src/test/java/com/mpush/client/MPushClientTest.java
import com.mpush.api.Client;
import com.mpush.api.ClientListener;
import com.mpush.util.DefaultLogger;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
int sleep = 1000;
if (args != null && args.length > 0) {
count = Integer.parseInt(args[0]);
if (args.length > 1) {
serverHost = args[1];
}
if (args.length > 2) {
sleep = Integer.parseInt(args[1]);
}
}
ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
ClientListener listener = new L(scheduledExecutor);
Client client = null;
String cacheDir = MPushClientTest.class.getResource("/").getFile();
for (int i = 0; i < count; i++) {
client = ClientConfig
.build()
.setPublicKey(publicKey)
//.setAllotServer(allocServer)
.setServerHost(serverHost)
.setServerPort(3000)
.setDeviceId("deviceId-test" + i)
.setOsName("android")
.setOsVersion("6.0")
.setClientVersion("2.0")
.setUserId("user-" + i)
.setTags("tag-" + i)
.setSessionStorageDir(cacheDir + i) | .setLogger(new DefaultLogger()) |
mpusher/mpush-client-java | src/main/java/com/mpush/api/connection/Connection.java | // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
| import java.nio.channels.SocketChannel;
import com.mpush.api.Client;
import com.mpush.api.protocol.Packet; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api.connection;
/**
* Created by ohun on 2015/12/22.
*
* @author [email protected] (夜色)
*/
public interface Connection {
void connect();
void close();
void reconnect();
| // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
// Path: src/main/java/com/mpush/api/connection/Connection.java
import java.nio.channels.SocketChannel;
import com.mpush.api.Client;
import com.mpush.api.protocol.Packet;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api.connection;
/**
* Created by ohun on 2015/12/22.
*
* @author [email protected] (夜色)
*/
public interface Connection {
void connect();
void close();
void reconnect();
| void send(Packet packet);//TODO add send Listener |
mpusher/mpush-client-java | src/main/java/com/mpush/api/connection/Connection.java | // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
| import java.nio.channels.SocketChannel;
import com.mpush.api.Client;
import com.mpush.api.protocol.Packet; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api.connection;
/**
* Created by ohun on 2015/12/22.
*
* @author [email protected] (夜色)
*/
public interface Connection {
void connect();
void close();
void reconnect();
void send(Packet packet);//TODO add send Listener
boolean isConnected();
boolean isAutoConnect();
boolean isReadTimeout();
boolean isWriteTimeout();
void setLastReadTime();
void setLastWriteTime();
void resetTimeout();
SessionContext getSessionContext();
SocketChannel getChannel();
| // Path: src/main/java/com/mpush/api/Client.java
// public interface Client extends MPushProtocol {
//
// void start();
//
// void stop();
//
// void destroy();
//
// boolean isRunning();
//
// void onNetStateChange(boolean isConnected);
//
// }
//
// Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
// Path: src/main/java/com/mpush/api/connection/Connection.java
import java.nio.channels.SocketChannel;
import com.mpush.api.Client;
import com.mpush.api.protocol.Packet;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api.connection;
/**
* Created by ohun on 2015/12/22.
*
* @author [email protected] (夜色)
*/
public interface Connection {
void connect();
void close();
void reconnect();
void send(Packet packet);//TODO add send Listener
boolean isConnected();
boolean isAutoConnect();
boolean isReadTimeout();
boolean isWriteTimeout();
void setLastReadTime();
void setLastWriteTime();
void resetTimeout();
SessionContext getSessionContext();
SocketChannel getChannel();
| Client getClient(); |
mpusher/mpush-client-java | src/main/java/com/mpush/api/Message.java | // Path: src/main/java/com/mpush/api/connection/Connection.java
// public interface Connection {
//
// void connect();
//
// void close();
//
// void reconnect();
//
// void send(Packet packet);//TODO add send Listener
//
// boolean isConnected();
//
// boolean isAutoConnect();
//
// boolean isReadTimeout();
//
// boolean isWriteTimeout();
//
// void setLastReadTime();
//
// void setLastWriteTime();
//
// void resetTimeout();
//
// SessionContext getSessionContext();
//
// SocketChannel getChannel();
//
// Client getClient();
// }
//
// Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
| import com.mpush.api.connection.Connection;
import com.mpush.api.protocol.Packet; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api;
/**
* Created by ohun on 2016/1/17.
*
* @author [email protected] (夜色)
*/
public interface Message {
Connection getConnection();
void decodeBody();
void encodeBody();
void send();
void sendRaw();
| // Path: src/main/java/com/mpush/api/connection/Connection.java
// public interface Connection {
//
// void connect();
//
// void close();
//
// void reconnect();
//
// void send(Packet packet);//TODO add send Listener
//
// boolean isConnected();
//
// boolean isAutoConnect();
//
// boolean isReadTimeout();
//
// boolean isWriteTimeout();
//
// void setLastReadTime();
//
// void setLastWriteTime();
//
// void resetTimeout();
//
// SessionContext getSessionContext();
//
// SocketChannel getChannel();
//
// Client getClient();
// }
//
// Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
// Path: src/main/java/com/mpush/api/Message.java
import com.mpush.api.connection.Connection;
import com.mpush.api.protocol.Packet;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api;
/**
* Created by ohun on 2016/1/17.
*
* @author [email protected] (夜色)
*/
public interface Message {
Connection getConnection();
void decodeBody();
void encodeBody();
void send();
void sendRaw();
| Packet getPacket(); |
mpusher/mpush-client-java | src/main/java/com/mpush/session/PersistentSession.java | // Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
//
// byte[] decrypt(byte[] data);
//
// byte[] encrypt(byte[] data);
//
// }
//
// Path: src/main/java/com/mpush/security/AesCipher.java
// public final class AesCipher implements Cipher {
// public final byte[] key;
// public final byte[] iv;
//
// public AesCipher(byte[] key, byte[] iv) {
// this.key = key;
// this.iv = iv;
// }
//
// @Override
// public byte[] decrypt(byte[] data) {
// return AESUtils.decrypt(data, key, iv);
// }
//
// @Override
// public byte[] encrypt(byte[] data) {
// return AESUtils.encrypt(data, key, iv);
// }
//
// @Override
// public String toString() {
// return toString(key) + ',' + toString(iv);
// }
//
// public String toString(byte[] a) {
// StringBuilder b = new StringBuilder();
// for (int i = 0; i < a.length; i++) {
// if (i != 0) b.append('|');
// b.append(a[i]);
// }
// return b.toString();
// }
//
// public static byte[] toArray(String str) {
// String[] a = str.split("\\|");
// if (a.length != CipherBox.INSTANCE.getAesKeyLength()) {
// return null;
// }
// byte[] bytes = new byte[a.length];
// for (int i = 0; i < a.length; i++) {
// bytes[i] = Byte.parseByte(a[i]);
// }
// return bytes;
// }
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
| import com.mpush.util.Strings;
import com.mpush.api.connection.Cipher;
import com.mpush.security.AesCipher; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.session;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public final class PersistentSession {
public String sessionId;
public long expireTime; | // Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
//
// byte[] decrypt(byte[] data);
//
// byte[] encrypt(byte[] data);
//
// }
//
// Path: src/main/java/com/mpush/security/AesCipher.java
// public final class AesCipher implements Cipher {
// public final byte[] key;
// public final byte[] iv;
//
// public AesCipher(byte[] key, byte[] iv) {
// this.key = key;
// this.iv = iv;
// }
//
// @Override
// public byte[] decrypt(byte[] data) {
// return AESUtils.decrypt(data, key, iv);
// }
//
// @Override
// public byte[] encrypt(byte[] data) {
// return AESUtils.encrypt(data, key, iv);
// }
//
// @Override
// public String toString() {
// return toString(key) + ',' + toString(iv);
// }
//
// public String toString(byte[] a) {
// StringBuilder b = new StringBuilder();
// for (int i = 0; i < a.length; i++) {
// if (i != 0) b.append('|');
// b.append(a[i]);
// }
// return b.toString();
// }
//
// public static byte[] toArray(String str) {
// String[] a = str.split("\\|");
// if (a.length != CipherBox.INSTANCE.getAesKeyLength()) {
// return null;
// }
// byte[] bytes = new byte[a.length];
// for (int i = 0; i < a.length; i++) {
// bytes[i] = Byte.parseByte(a[i]);
// }
// return bytes;
// }
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
// Path: src/main/java/com/mpush/session/PersistentSession.java
import com.mpush.util.Strings;
import com.mpush.api.connection.Cipher;
import com.mpush.security.AesCipher;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.session;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public final class PersistentSession {
public String sessionId;
public long expireTime; | public Cipher cipher; |
mpusher/mpush-client-java | src/main/java/com/mpush/session/PersistentSession.java | // Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
//
// byte[] decrypt(byte[] data);
//
// byte[] encrypt(byte[] data);
//
// }
//
// Path: src/main/java/com/mpush/security/AesCipher.java
// public final class AesCipher implements Cipher {
// public final byte[] key;
// public final byte[] iv;
//
// public AesCipher(byte[] key, byte[] iv) {
// this.key = key;
// this.iv = iv;
// }
//
// @Override
// public byte[] decrypt(byte[] data) {
// return AESUtils.decrypt(data, key, iv);
// }
//
// @Override
// public byte[] encrypt(byte[] data) {
// return AESUtils.encrypt(data, key, iv);
// }
//
// @Override
// public String toString() {
// return toString(key) + ',' + toString(iv);
// }
//
// public String toString(byte[] a) {
// StringBuilder b = new StringBuilder();
// for (int i = 0; i < a.length; i++) {
// if (i != 0) b.append('|');
// b.append(a[i]);
// }
// return b.toString();
// }
//
// public static byte[] toArray(String str) {
// String[] a = str.split("\\|");
// if (a.length != CipherBox.INSTANCE.getAesKeyLength()) {
// return null;
// }
// byte[] bytes = new byte[a.length];
// for (int i = 0; i < a.length; i++) {
// bytes[i] = Byte.parseByte(a[i]);
// }
// return bytes;
// }
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
| import com.mpush.util.Strings;
import com.mpush.api.connection.Cipher;
import com.mpush.security.AesCipher; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.session;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public final class PersistentSession {
public String sessionId;
public long expireTime;
public Cipher cipher;
public boolean isExpired() {
return expireTime < System.currentTimeMillis();
}
public static String encode(PersistentSession session) {
return session.sessionId
+ "," + session.expireTime
+ "," + session.cipher.toString();
}
public static PersistentSession decode(String value) {
String[] array = value.split(",");
if (array.length != 4) return null;
PersistentSession session = new PersistentSession();
session.sessionId = array[0]; | // Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
//
// byte[] decrypt(byte[] data);
//
// byte[] encrypt(byte[] data);
//
// }
//
// Path: src/main/java/com/mpush/security/AesCipher.java
// public final class AesCipher implements Cipher {
// public final byte[] key;
// public final byte[] iv;
//
// public AesCipher(byte[] key, byte[] iv) {
// this.key = key;
// this.iv = iv;
// }
//
// @Override
// public byte[] decrypt(byte[] data) {
// return AESUtils.decrypt(data, key, iv);
// }
//
// @Override
// public byte[] encrypt(byte[] data) {
// return AESUtils.encrypt(data, key, iv);
// }
//
// @Override
// public String toString() {
// return toString(key) + ',' + toString(iv);
// }
//
// public String toString(byte[] a) {
// StringBuilder b = new StringBuilder();
// for (int i = 0; i < a.length; i++) {
// if (i != 0) b.append('|');
// b.append(a[i]);
// }
// return b.toString();
// }
//
// public static byte[] toArray(String str) {
// String[] a = str.split("\\|");
// if (a.length != CipherBox.INSTANCE.getAesKeyLength()) {
// return null;
// }
// byte[] bytes = new byte[a.length];
// for (int i = 0; i < a.length; i++) {
// bytes[i] = Byte.parseByte(a[i]);
// }
// return bytes;
// }
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
// Path: src/main/java/com/mpush/session/PersistentSession.java
import com.mpush.util.Strings;
import com.mpush.api.connection.Cipher;
import com.mpush.security.AesCipher;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.session;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public final class PersistentSession {
public String sessionId;
public long expireTime;
public Cipher cipher;
public boolean isExpired() {
return expireTime < System.currentTimeMillis();
}
public static String encode(PersistentSession session) {
return session.sessionId
+ "," + session.expireTime
+ "," + session.cipher.toString();
}
public static PersistentSession decode(String value) {
String[] array = value.split(",");
if (array.length != 4) return null;
PersistentSession session = new PersistentSession();
session.sessionId = array[0]; | session.expireTime = Strings.toLong(array[1], 0); |
mpusher/mpush-client-java | src/main/java/com/mpush/session/PersistentSession.java | // Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
//
// byte[] decrypt(byte[] data);
//
// byte[] encrypt(byte[] data);
//
// }
//
// Path: src/main/java/com/mpush/security/AesCipher.java
// public final class AesCipher implements Cipher {
// public final byte[] key;
// public final byte[] iv;
//
// public AesCipher(byte[] key, byte[] iv) {
// this.key = key;
// this.iv = iv;
// }
//
// @Override
// public byte[] decrypt(byte[] data) {
// return AESUtils.decrypt(data, key, iv);
// }
//
// @Override
// public byte[] encrypt(byte[] data) {
// return AESUtils.encrypt(data, key, iv);
// }
//
// @Override
// public String toString() {
// return toString(key) + ',' + toString(iv);
// }
//
// public String toString(byte[] a) {
// StringBuilder b = new StringBuilder();
// for (int i = 0; i < a.length; i++) {
// if (i != 0) b.append('|');
// b.append(a[i]);
// }
// return b.toString();
// }
//
// public static byte[] toArray(String str) {
// String[] a = str.split("\\|");
// if (a.length != CipherBox.INSTANCE.getAesKeyLength()) {
// return null;
// }
// byte[] bytes = new byte[a.length];
// for (int i = 0; i < a.length; i++) {
// bytes[i] = Byte.parseByte(a[i]);
// }
// return bytes;
// }
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
| import com.mpush.util.Strings;
import com.mpush.api.connection.Cipher;
import com.mpush.security.AesCipher; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.session;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public final class PersistentSession {
public String sessionId;
public long expireTime;
public Cipher cipher;
public boolean isExpired() {
return expireTime < System.currentTimeMillis();
}
public static String encode(PersistentSession session) {
return session.sessionId
+ "," + session.expireTime
+ "," + session.cipher.toString();
}
public static PersistentSession decode(String value) {
String[] array = value.split(",");
if (array.length != 4) return null;
PersistentSession session = new PersistentSession();
session.sessionId = array[0];
session.expireTime = Strings.toLong(array[1], 0); | // Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
//
// byte[] decrypt(byte[] data);
//
// byte[] encrypt(byte[] data);
//
// }
//
// Path: src/main/java/com/mpush/security/AesCipher.java
// public final class AesCipher implements Cipher {
// public final byte[] key;
// public final byte[] iv;
//
// public AesCipher(byte[] key, byte[] iv) {
// this.key = key;
// this.iv = iv;
// }
//
// @Override
// public byte[] decrypt(byte[] data) {
// return AESUtils.decrypt(data, key, iv);
// }
//
// @Override
// public byte[] encrypt(byte[] data) {
// return AESUtils.encrypt(data, key, iv);
// }
//
// @Override
// public String toString() {
// return toString(key) + ',' + toString(iv);
// }
//
// public String toString(byte[] a) {
// StringBuilder b = new StringBuilder();
// for (int i = 0; i < a.length; i++) {
// if (i != 0) b.append('|');
// b.append(a[i]);
// }
// return b.toString();
// }
//
// public static byte[] toArray(String str) {
// String[] a = str.split("\\|");
// if (a.length != CipherBox.INSTANCE.getAesKeyLength()) {
// return null;
// }
// byte[] bytes = new byte[a.length];
// for (int i = 0; i < a.length; i++) {
// bytes[i] = Byte.parseByte(a[i]);
// }
// return bytes;
// }
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
// Path: src/main/java/com/mpush/session/PersistentSession.java
import com.mpush.util.Strings;
import com.mpush.api.connection.Cipher;
import com.mpush.security.AesCipher;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.session;
/**
* Created by ohun on 2016/1/25.
*
* @author [email protected] (夜色)
*/
public final class PersistentSession {
public String sessionId;
public long expireTime;
public Cipher cipher;
public boolean isExpired() {
return expireTime < System.currentTimeMillis();
}
public static String encode(PersistentSession session) {
return session.sessionId
+ "," + session.expireTime
+ "," + session.cipher.toString();
}
public static PersistentSession decode(String value) {
String[] array = value.split(",");
if (array.length != 4) return null;
PersistentSession session = new PersistentSession();
session.sessionId = array[0];
session.expireTime = Strings.toLong(array[1], 0); | byte[] key = AesCipher.toArray(array[2]); |
mpusher/mpush-client-java | src/main/java/com/mpush/security/AesCipher.java | // Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
//
// byte[] decrypt(byte[] data);
//
// byte[] encrypt(byte[] data);
//
// }
//
// Path: src/main/java/com/mpush/util/crypto/AESUtils.java
// public final class AESUtils {
// public static final String KEY_ALGORITHM = "AES";
// public static final String KEY_ALGORITHM_PADDING = "AES/CBC/PKCS5Padding";
//
//
// public static byte[] encrypt(byte[] data, byte[] encryptKey, byte[] iv) {
// IvParameterSpec zeroIv = new IvParameterSpec(iv);
// SecretKeySpec key = new SecretKeySpec(encryptKey, KEY_ALGORITHM);
// try {
// Cipher cipher = Cipher.getInstance(KEY_ALGORITHM_PADDING);
// cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
// return cipher.doFinal(data);
// } catch (Exception e) {
// ClientConfig.I.getLogger().e(e, "encrypt ex, decryptKey=%s", encryptKey);
// }
// return Constants.EMPTY_BYTES;
// }
//
// public static byte[] decrypt(byte[] data, byte[] decryptKey, byte[] iv) {
// IvParameterSpec zeroIv = new IvParameterSpec(iv);
// SecretKeySpec key = new SecretKeySpec(decryptKey, KEY_ALGORITHM);
// try {
// Cipher cipher = Cipher.getInstance(KEY_ALGORITHM_PADDING);
// cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);
// return cipher.doFinal(data);
// } catch (Exception e) {
// ClientConfig.I.getLogger().e(e, "decrypt ex, decryptKey=%s", decryptKey);
// }
// return Constants.EMPTY_BYTES;
// }
// }
| import com.mpush.util.crypto.AESUtils;
import com.mpush.api.connection.Cipher; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.security;
/**
* Created by ohun on 2015/12/28.
*
* @author [email protected] (夜色)
*/
public final class AesCipher implements Cipher {
public final byte[] key;
public final byte[] iv;
public AesCipher(byte[] key, byte[] iv) {
this.key = key;
this.iv = iv;
}
@Override
public byte[] decrypt(byte[] data) { | // Path: src/main/java/com/mpush/api/connection/Cipher.java
// public interface Cipher {
//
// byte[] decrypt(byte[] data);
//
// byte[] encrypt(byte[] data);
//
// }
//
// Path: src/main/java/com/mpush/util/crypto/AESUtils.java
// public final class AESUtils {
// public static final String KEY_ALGORITHM = "AES";
// public static final String KEY_ALGORITHM_PADDING = "AES/CBC/PKCS5Padding";
//
//
// public static byte[] encrypt(byte[] data, byte[] encryptKey, byte[] iv) {
// IvParameterSpec zeroIv = new IvParameterSpec(iv);
// SecretKeySpec key = new SecretKeySpec(encryptKey, KEY_ALGORITHM);
// try {
// Cipher cipher = Cipher.getInstance(KEY_ALGORITHM_PADDING);
// cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
// return cipher.doFinal(data);
// } catch (Exception e) {
// ClientConfig.I.getLogger().e(e, "encrypt ex, decryptKey=%s", encryptKey);
// }
// return Constants.EMPTY_BYTES;
// }
//
// public static byte[] decrypt(byte[] data, byte[] decryptKey, byte[] iv) {
// IvParameterSpec zeroIv = new IvParameterSpec(iv);
// SecretKeySpec key = new SecretKeySpec(decryptKey, KEY_ALGORITHM);
// try {
// Cipher cipher = Cipher.getInstance(KEY_ALGORITHM_PADDING);
// cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);
// return cipher.doFinal(data);
// } catch (Exception e) {
// ClientConfig.I.getLogger().e(e, "decrypt ex, decryptKey=%s", decryptKey);
// }
// return Constants.EMPTY_BYTES;
// }
// }
// Path: src/main/java/com/mpush/security/AesCipher.java
import com.mpush.util.crypto.AESUtils;
import com.mpush.api.connection.Cipher;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.security;
/**
* Created by ohun on 2015/12/28.
*
* @author [email protected] (夜色)
*/
public final class AesCipher implements Cipher {
public final byte[] key;
public final byte[] iv;
public AesCipher(byte[] key, byte[] iv) {
this.key = key;
this.iv = iv;
}
@Override
public byte[] decrypt(byte[] data) { | return AESUtils.decrypt(data, key, iv); |
mpusher/mpush-client-java | src/main/java/com/mpush/util/crypto/Base64.java | // Path: src/main/java/com/mpush/api/Constants.java
// public interface Constants {
// Charset UTF_8 = Charset.forName("UTF-8");
//
// int DEFAULT_SO_TIMEOUT = 1000 * 3;//客户端连接超时时间
//
// int DEFAULT_WRITE_TIMEOUT = 1000 * 10;//10s默认packet写超时
//
// byte[] EMPTY_BYTES = new byte[0];
//
// int DEF_HEARTBEAT = 4 * 60 * 1000;//5min 默认心跳时间
//
// int DEF_COMPRESS_LIMIT = 1024;//1k 启用压缩阈值
//
// String DEF_OS_NAME = "android";//客户端OS
//
// int MAX_RESTART_COUNT = 10;//客户端重连次数超过该值,重连线程休眠10min后再重试
// int MAX_TOTAL_RESTART_COUNT = 1000;//客户端重连次数超过该值,将不再尝试重连
//
// int MAX_HB_TIMEOUT_COUNT = 2;
//
// String HTTP_HEAD_READ_TIMEOUT = "readTimeout";
// }
| import com.mpush.api.Constants;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays; | * Decodes all bytes from the input byte array using the {@link Base64}
* encoding scheme, writing the results into a newly-allocated output
* byte array. The returned byte array is of the length of the resulting
* bytes.
*
* @param src the byte array to decode
* @return A newly-allocated byte array containing the decoded bytes.
* @throws IllegalArgumentException if {@code src} is not in valid Base64 scheme
*/
public byte[] decode(byte[] src) {
byte[] dst = new byte[outLength(src, 0, src.length)];
int ret = decode0(src, 0, src.length, dst);
if (ret != dst.length) {
dst = Arrays.copyOf(dst, ret);
}
return dst;
}
/**
* Decodes a Base64 encoded String into a newly-allocated byte array
* using the {@link Base64} encoding scheme.
* <p>
* An invocation of this method has exactly the same effect as invoking
* {@code decode(src.getBytes(StandardCharsets.ISO_8859_1))}
*
* @param src the string to decode
* @return A newly-allocated byte array containing the decoded bytes.
* @throws IllegalArgumentException if {@code src} is not in valid Base64 scheme
*/
public byte[] decode(String src) { | // Path: src/main/java/com/mpush/api/Constants.java
// public interface Constants {
// Charset UTF_8 = Charset.forName("UTF-8");
//
// int DEFAULT_SO_TIMEOUT = 1000 * 3;//客户端连接超时时间
//
// int DEFAULT_WRITE_TIMEOUT = 1000 * 10;//10s默认packet写超时
//
// byte[] EMPTY_BYTES = new byte[0];
//
// int DEF_HEARTBEAT = 4 * 60 * 1000;//5min 默认心跳时间
//
// int DEF_COMPRESS_LIMIT = 1024;//1k 启用压缩阈值
//
// String DEF_OS_NAME = "android";//客户端OS
//
// int MAX_RESTART_COUNT = 10;//客户端重连次数超过该值,重连线程休眠10min后再重试
// int MAX_TOTAL_RESTART_COUNT = 1000;//客户端重连次数超过该值,将不再尝试重连
//
// int MAX_HB_TIMEOUT_COUNT = 2;
//
// String HTTP_HEAD_READ_TIMEOUT = "readTimeout";
// }
// Path: src/main/java/com/mpush/util/crypto/Base64.java
import com.mpush.api.Constants;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
* Decodes all bytes from the input byte array using the {@link Base64}
* encoding scheme, writing the results into a newly-allocated output
* byte array. The returned byte array is of the length of the resulting
* bytes.
*
* @param src the byte array to decode
* @return A newly-allocated byte array containing the decoded bytes.
* @throws IllegalArgumentException if {@code src} is not in valid Base64 scheme
*/
public byte[] decode(byte[] src) {
byte[] dst = new byte[outLength(src, 0, src.length)];
int ret = decode0(src, 0, src.length, dst);
if (ret != dst.length) {
dst = Arrays.copyOf(dst, ret);
}
return dst;
}
/**
* Decodes a Base64 encoded String into a newly-allocated byte array
* using the {@link Base64} encoding scheme.
* <p>
* An invocation of this method has exactly the same effect as invoking
* {@code decode(src.getBytes(StandardCharsets.ISO_8859_1))}
*
* @param src the string to decode
* @return A newly-allocated byte array containing the decoded bytes.
* @throws IllegalArgumentException if {@code src} is not in valid Base64 scheme
*/
public byte[] decode(String src) { | return decode(src.getBytes(Constants.UTF_8)); |
mpusher/mpush-client-java | src/main/java/com/mpush/api/ack/AckContext.java | // Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
| import com.mpush.api.protocol.Packet; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api.ack;
/**
* Created by ohun on 2016/11/13.
*
* @author [email protected] (夜色)
*/
public class AckContext {
public AckCallback callback;
public AckModel ackModel = AckModel.AUTO_ACK;
public int timeout = 1000; | // Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
// Path: src/main/java/com/mpush/api/ack/AckContext.java
import com.mpush.api.protocol.Packet;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api.ack;
/**
* Created by ohun on 2016/11/13.
*
* @author [email protected] (夜色)
*/
public class AckContext {
public AckCallback callback;
public AckModel ackModel = AckModel.AUTO_ACK;
public int timeout = 1000; | public Packet request; |
mpusher/mpush-client-java | src/main/java/com/mpush/api/ack/AckModel.java | // Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
| import com.mpush.api.protocol.Packet; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api.ack;
/**
* Created by ohun on 16/9/6.
*
* @author [email protected] (夜色)
*/
public enum AckModel {
NO_ACK((byte) 0),//不需要ACK | // Path: src/main/java/com/mpush/api/protocol/Packet.java
// public final class Packet {
// public static final int HEADER_LEN = 13;//packet包头协议长度
//
// public static final byte FLAG_CRYPTO = 0x01;//packet包启用加密
// public static final byte FLAG_COMPRESS = 0x02;//packet包启用压缩
// public static final byte FLAG_BIZ_ACK = 0x04;
// public static final byte FLAG_AUTO_ACK = 0x08;
//
// public static final byte HB_PACKET_BYTE = -33;
// public static final Packet HB_PACKET = new Packet(Command.HEARTBEAT);
//
// public byte cmd; //命令
// public short cc; //校验码 暂时没有用到
// public byte flags; //特性,如是否加密,是否压缩等
// public int sessionId; // 会话id
// public byte lrc; // 校验,纵向冗余校验。只校验header
// public byte[] body;
//
// public Packet(byte cmd) {
// this.cmd = cmd;
// }
//
// public Packet(byte cmd, int sessionId) {
// this.cmd = cmd;
// this.sessionId = sessionId;
// }
//
// public Packet(Command cmd) {
// this.cmd = cmd.cmd;
// }
//
// public Packet(Command cmd, int sessionId) {
// this.cmd = cmd.cmd;
// this.sessionId = sessionId;
// }
//
// public int getBodyLength() {
// return body == null ? 0 : body.length;
// }
//
// public void addFlag(byte flag) {
// this.flags |= flag;
// }
//
// public boolean hasFlag(byte flag) {
// return (flags & flag) == flag;
// }
//
// public short calcCheckCode() {
// short checkCode = 0;
// if (body != null) {
// for (int i = 0; i < body.length; i++) {
// checkCode += (body[i] & 0x0ff);
// }
// }
// return checkCode;
// }
//
// public byte calcLrc() {
// byte[] data = ByteBuffer.allocate(HEADER_LEN - 1)
// .putInt(getBodyLength())
// .put(cmd)
// .putShort(cc)
// .put(flags)
// .putInt(sessionId)
// .array();
// byte lrc = 0;
// for (int i = 0; i < data.length; i++) {
// lrc ^= data[i];
// }
// return lrc;
// }
//
// public boolean validCheckCode() {
// return calcCheckCode() == cc;
// }
//
// public boolean validLrc() {
// return (lrc ^ calcLrc()) == 0;
// }
//
// @Override
// public String toString() {
// return "Packet{" +
// "cmd=" + cmd +
// ", cc=" + cc +
// ", flags=" + flags +
// ", sessionId=" + sessionId +
// ", lrc=" + lrc +
// ", body=" + (body == null ? 0 : body.length) +
// '}';
// }
// }
// Path: src/main/java/com/mpush/api/ack/AckModel.java
import com.mpush.api.protocol.Packet;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.api.ack;
/**
* Created by ohun on 16/9/6.
*
* @author [email protected] (夜色)
*/
public enum AckModel {
NO_ACK((byte) 0),//不需要ACK | AUTO_ACK(Packet.FLAG_AUTO_ACK),//客户端收到消息后自动确认消息 |
mpusher/mpush-client-java | src/main/java/com/mpush/util/crypto/MD5Utils.java | // Path: src/main/java/com/mpush/util/IOUtils.java
// public final class IOUtils {
//
// public static void close(Closeable closeable) {
// if (closeable != null) {
// try {
// closeable.close();
// } catch (Exception e) {
// }
// }
// }
//
// public static byte[] compress(byte[] data) {
// ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length / 4);
// DeflaterOutputStream zipOut = new DeflaterOutputStream(byteStream);
// try {
// zipOut.write(data);
// zipOut.finish();
// zipOut.close();
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(zipOut);
// }
// return byteStream.toByteArray();
// }
//
// public static byte[] uncompress(byte[] data) {
// InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data));
// ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 4);
// byte[] buffer = new byte[1024];
// int length;
// try {
// while ((length = in.read(buffer)) != -1) {
// out.write(buffer, 0, length);
// }
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(in);
// }
// return out.toByteArray();
// }
// }
//
// Path: src/main/java/com/mpush/api/Constants.java
// public interface Constants {
// Charset UTF_8 = Charset.forName("UTF-8");
//
// int DEFAULT_SO_TIMEOUT = 1000 * 3;//客户端连接超时时间
//
// int DEFAULT_WRITE_TIMEOUT = 1000 * 10;//10s默认packet写超时
//
// byte[] EMPTY_BYTES = new byte[0];
//
// int DEF_HEARTBEAT = 4 * 60 * 1000;//5min 默认心跳时间
//
// int DEF_COMPRESS_LIMIT = 1024;//1k 启用压缩阈值
//
// String DEF_OS_NAME = "android";//客户端OS
//
// int MAX_RESTART_COUNT = 10;//客户端重连次数超过该值,重连线程休眠10min后再重试
// int MAX_TOTAL_RESTART_COUNT = 1000;//客户端重连次数超过该值,将不再尝试重连
//
// int MAX_HB_TIMEOUT_COUNT = 2;
//
// String HTTP_HEAD_READ_TIMEOUT = "readTimeout";
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
| import java.security.MessageDigest;
import com.mpush.util.IOUtils;
import com.mpush.api.Constants;
import com.mpush.util.Strings;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.util.crypto;
/**
* Created by ohun on 2015/12/25.
*
* @author [email protected] (夜色)
*/
public final class MD5Utils {
public static String encrypt(File file) {
InputStream in = null;
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
byte[] buffer = new byte[10240];//10k
int readLen;
while ((readLen = in.read(buffer)) != -1) {
digest.update(buffer, 0, readLen);
}
return toHex(digest.digest());
} catch (Exception e) { | // Path: src/main/java/com/mpush/util/IOUtils.java
// public final class IOUtils {
//
// public static void close(Closeable closeable) {
// if (closeable != null) {
// try {
// closeable.close();
// } catch (Exception e) {
// }
// }
// }
//
// public static byte[] compress(byte[] data) {
// ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length / 4);
// DeflaterOutputStream zipOut = new DeflaterOutputStream(byteStream);
// try {
// zipOut.write(data);
// zipOut.finish();
// zipOut.close();
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(zipOut);
// }
// return byteStream.toByteArray();
// }
//
// public static byte[] uncompress(byte[] data) {
// InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data));
// ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 4);
// byte[] buffer = new byte[1024];
// int length;
// try {
// while ((length = in.read(buffer)) != -1) {
// out.write(buffer, 0, length);
// }
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(in);
// }
// return out.toByteArray();
// }
// }
//
// Path: src/main/java/com/mpush/api/Constants.java
// public interface Constants {
// Charset UTF_8 = Charset.forName("UTF-8");
//
// int DEFAULT_SO_TIMEOUT = 1000 * 3;//客户端连接超时时间
//
// int DEFAULT_WRITE_TIMEOUT = 1000 * 10;//10s默认packet写超时
//
// byte[] EMPTY_BYTES = new byte[0];
//
// int DEF_HEARTBEAT = 4 * 60 * 1000;//5min 默认心跳时间
//
// int DEF_COMPRESS_LIMIT = 1024;//1k 启用压缩阈值
//
// String DEF_OS_NAME = "android";//客户端OS
//
// int MAX_RESTART_COUNT = 10;//客户端重连次数超过该值,重连线程休眠10min后再重试
// int MAX_TOTAL_RESTART_COUNT = 1000;//客户端重连次数超过该值,将不再尝试重连
//
// int MAX_HB_TIMEOUT_COUNT = 2;
//
// String HTTP_HEAD_READ_TIMEOUT = "readTimeout";
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
// Path: src/main/java/com/mpush/util/crypto/MD5Utils.java
import java.security.MessageDigest;
import com.mpush.util.IOUtils;
import com.mpush.api.Constants;
import com.mpush.util.Strings;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.util.crypto;
/**
* Created by ohun on 2015/12/25.
*
* @author [email protected] (夜色)
*/
public final class MD5Utils {
public static String encrypt(File file) {
InputStream in = null;
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
byte[] buffer = new byte[10240];//10k
int readLen;
while ((readLen = in.read(buffer)) != -1) {
digest.update(buffer, 0, readLen);
}
return toHex(digest.digest());
} catch (Exception e) { | return Strings.EMPTY; |
mpusher/mpush-client-java | src/main/java/com/mpush/util/crypto/MD5Utils.java | // Path: src/main/java/com/mpush/util/IOUtils.java
// public final class IOUtils {
//
// public static void close(Closeable closeable) {
// if (closeable != null) {
// try {
// closeable.close();
// } catch (Exception e) {
// }
// }
// }
//
// public static byte[] compress(byte[] data) {
// ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length / 4);
// DeflaterOutputStream zipOut = new DeflaterOutputStream(byteStream);
// try {
// zipOut.write(data);
// zipOut.finish();
// zipOut.close();
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(zipOut);
// }
// return byteStream.toByteArray();
// }
//
// public static byte[] uncompress(byte[] data) {
// InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data));
// ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 4);
// byte[] buffer = new byte[1024];
// int length;
// try {
// while ((length = in.read(buffer)) != -1) {
// out.write(buffer, 0, length);
// }
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(in);
// }
// return out.toByteArray();
// }
// }
//
// Path: src/main/java/com/mpush/api/Constants.java
// public interface Constants {
// Charset UTF_8 = Charset.forName("UTF-8");
//
// int DEFAULT_SO_TIMEOUT = 1000 * 3;//客户端连接超时时间
//
// int DEFAULT_WRITE_TIMEOUT = 1000 * 10;//10s默认packet写超时
//
// byte[] EMPTY_BYTES = new byte[0];
//
// int DEF_HEARTBEAT = 4 * 60 * 1000;//5min 默认心跳时间
//
// int DEF_COMPRESS_LIMIT = 1024;//1k 启用压缩阈值
//
// String DEF_OS_NAME = "android";//客户端OS
//
// int MAX_RESTART_COUNT = 10;//客户端重连次数超过该值,重连线程休眠10min后再重试
// int MAX_TOTAL_RESTART_COUNT = 1000;//客户端重连次数超过该值,将不再尝试重连
//
// int MAX_HB_TIMEOUT_COUNT = 2;
//
// String HTTP_HEAD_READ_TIMEOUT = "readTimeout";
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
| import java.security.MessageDigest;
import com.mpush.util.IOUtils;
import com.mpush.api.Constants;
import com.mpush.util.Strings;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.util.crypto;
/**
* Created by ohun on 2015/12/25.
*
* @author [email protected] (夜色)
*/
public final class MD5Utils {
public static String encrypt(File file) {
InputStream in = null;
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
byte[] buffer = new byte[10240];//10k
int readLen;
while ((readLen = in.read(buffer)) != -1) {
digest.update(buffer, 0, readLen);
}
return toHex(digest.digest());
} catch (Exception e) {
return Strings.EMPTY;
} finally { | // Path: src/main/java/com/mpush/util/IOUtils.java
// public final class IOUtils {
//
// public static void close(Closeable closeable) {
// if (closeable != null) {
// try {
// closeable.close();
// } catch (Exception e) {
// }
// }
// }
//
// public static byte[] compress(byte[] data) {
// ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length / 4);
// DeflaterOutputStream zipOut = new DeflaterOutputStream(byteStream);
// try {
// zipOut.write(data);
// zipOut.finish();
// zipOut.close();
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(zipOut);
// }
// return byteStream.toByteArray();
// }
//
// public static byte[] uncompress(byte[] data) {
// InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data));
// ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 4);
// byte[] buffer = new byte[1024];
// int length;
// try {
// while ((length = in.read(buffer)) != -1) {
// out.write(buffer, 0, length);
// }
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(in);
// }
// return out.toByteArray();
// }
// }
//
// Path: src/main/java/com/mpush/api/Constants.java
// public interface Constants {
// Charset UTF_8 = Charset.forName("UTF-8");
//
// int DEFAULT_SO_TIMEOUT = 1000 * 3;//客户端连接超时时间
//
// int DEFAULT_WRITE_TIMEOUT = 1000 * 10;//10s默认packet写超时
//
// byte[] EMPTY_BYTES = new byte[0];
//
// int DEF_HEARTBEAT = 4 * 60 * 1000;//5min 默认心跳时间
//
// int DEF_COMPRESS_LIMIT = 1024;//1k 启用压缩阈值
//
// String DEF_OS_NAME = "android";//客户端OS
//
// int MAX_RESTART_COUNT = 10;//客户端重连次数超过该值,重连线程休眠10min后再重试
// int MAX_TOTAL_RESTART_COUNT = 1000;//客户端重连次数超过该值,将不再尝试重连
//
// int MAX_HB_TIMEOUT_COUNT = 2;
//
// String HTTP_HEAD_READ_TIMEOUT = "readTimeout";
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
// Path: src/main/java/com/mpush/util/crypto/MD5Utils.java
import java.security.MessageDigest;
import com.mpush.util.IOUtils;
import com.mpush.api.Constants;
import com.mpush.util.Strings;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.util.crypto;
/**
* Created by ohun on 2015/12/25.
*
* @author [email protected] (夜色)
*/
public final class MD5Utils {
public static String encrypt(File file) {
InputStream in = null;
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
byte[] buffer = new byte[10240];//10k
int readLen;
while ((readLen = in.read(buffer)) != -1) {
digest.update(buffer, 0, readLen);
}
return toHex(digest.digest());
} catch (Exception e) {
return Strings.EMPTY;
} finally { | IOUtils.close(in); |
mpusher/mpush-client-java | src/main/java/com/mpush/util/crypto/MD5Utils.java | // Path: src/main/java/com/mpush/util/IOUtils.java
// public final class IOUtils {
//
// public static void close(Closeable closeable) {
// if (closeable != null) {
// try {
// closeable.close();
// } catch (Exception e) {
// }
// }
// }
//
// public static byte[] compress(byte[] data) {
// ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length / 4);
// DeflaterOutputStream zipOut = new DeflaterOutputStream(byteStream);
// try {
// zipOut.write(data);
// zipOut.finish();
// zipOut.close();
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(zipOut);
// }
// return byteStream.toByteArray();
// }
//
// public static byte[] uncompress(byte[] data) {
// InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data));
// ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 4);
// byte[] buffer = new byte[1024];
// int length;
// try {
// while ((length = in.read(buffer)) != -1) {
// out.write(buffer, 0, length);
// }
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(in);
// }
// return out.toByteArray();
// }
// }
//
// Path: src/main/java/com/mpush/api/Constants.java
// public interface Constants {
// Charset UTF_8 = Charset.forName("UTF-8");
//
// int DEFAULT_SO_TIMEOUT = 1000 * 3;//客户端连接超时时间
//
// int DEFAULT_WRITE_TIMEOUT = 1000 * 10;//10s默认packet写超时
//
// byte[] EMPTY_BYTES = new byte[0];
//
// int DEF_HEARTBEAT = 4 * 60 * 1000;//5min 默认心跳时间
//
// int DEF_COMPRESS_LIMIT = 1024;//1k 启用压缩阈值
//
// String DEF_OS_NAME = "android";//客户端OS
//
// int MAX_RESTART_COUNT = 10;//客户端重连次数超过该值,重连线程休眠10min后再重试
// int MAX_TOTAL_RESTART_COUNT = 1000;//客户端重连次数超过该值,将不再尝试重连
//
// int MAX_HB_TIMEOUT_COUNT = 2;
//
// String HTTP_HEAD_READ_TIMEOUT = "readTimeout";
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
| import java.security.MessageDigest;
import com.mpush.util.IOUtils;
import com.mpush.api.Constants;
import com.mpush.util.Strings;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.util.crypto;
/**
* Created by ohun on 2015/12/25.
*
* @author [email protected] (夜色)
*/
public final class MD5Utils {
public static String encrypt(File file) {
InputStream in = null;
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
byte[] buffer = new byte[10240];//10k
int readLen;
while ((readLen = in.read(buffer)) != -1) {
digest.update(buffer, 0, readLen);
}
return toHex(digest.digest());
} catch (Exception e) {
return Strings.EMPTY;
} finally {
IOUtils.close(in);
}
}
public static String encrypt(String text) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5"); | // Path: src/main/java/com/mpush/util/IOUtils.java
// public final class IOUtils {
//
// public static void close(Closeable closeable) {
// if (closeable != null) {
// try {
// closeable.close();
// } catch (Exception e) {
// }
// }
// }
//
// public static byte[] compress(byte[] data) {
// ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length / 4);
// DeflaterOutputStream zipOut = new DeflaterOutputStream(byteStream);
// try {
// zipOut.write(data);
// zipOut.finish();
// zipOut.close();
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(zipOut);
// }
// return byteStream.toByteArray();
// }
//
// public static byte[] uncompress(byte[] data) {
// InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data));
// ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 4);
// byte[] buffer = new byte[1024];
// int length;
// try {
// while ((length = in.read(buffer)) != -1) {
// out.write(buffer, 0, length);
// }
// } catch (IOException e) {
// return Constants.EMPTY_BYTES;
// } finally {
// close(in);
// }
// return out.toByteArray();
// }
// }
//
// Path: src/main/java/com/mpush/api/Constants.java
// public interface Constants {
// Charset UTF_8 = Charset.forName("UTF-8");
//
// int DEFAULT_SO_TIMEOUT = 1000 * 3;//客户端连接超时时间
//
// int DEFAULT_WRITE_TIMEOUT = 1000 * 10;//10s默认packet写超时
//
// byte[] EMPTY_BYTES = new byte[0];
//
// int DEF_HEARTBEAT = 4 * 60 * 1000;//5min 默认心跳时间
//
// int DEF_COMPRESS_LIMIT = 1024;//1k 启用压缩阈值
//
// String DEF_OS_NAME = "android";//客户端OS
//
// int MAX_RESTART_COUNT = 10;//客户端重连次数超过该值,重连线程休眠10min后再重试
// int MAX_TOTAL_RESTART_COUNT = 1000;//客户端重连次数超过该值,将不再尝试重连
//
// int MAX_HB_TIMEOUT_COUNT = 2;
//
// String HTTP_HEAD_READ_TIMEOUT = "readTimeout";
// }
//
// Path: src/main/java/com/mpush/util/Strings.java
// public final class Strings {
// public static final String EMPTY = "";
//
// public static boolean isBlank(CharSequence text) {
// if (text == null || text.length() == 0) return true;
// for (int i = 0, L = text.length(); i < L; i++) {
// if (!Character.isWhitespace(text.charAt(i))) return false;
// }
// return true;
// }
//
// public static long toLong(String text, long defaultVal) {
// try {
// return Long.parseLong(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
//
// public static int toInt(String text, int defaultVal) {
// try {
// return Integer.parseInt(text);
// } catch (NumberFormatException e) {
// }
// return defaultVal;
// }
// }
// Path: src/main/java/com/mpush/util/crypto/MD5Utils.java
import java.security.MessageDigest;
import com.mpush.util.IOUtils;
import com.mpush.api.Constants;
import com.mpush.util.Strings;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.util.crypto;
/**
* Created by ohun on 2015/12/25.
*
* @author [email protected] (夜色)
*/
public final class MD5Utils {
public static String encrypt(File file) {
InputStream in = null;
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
byte[] buffer = new byte[10240];//10k
int readLen;
while ((readLen = in.read(buffer)) != -1) {
digest.update(buffer, 0, readLen);
}
return toHex(digest.digest());
} catch (Exception e) {
return Strings.EMPTY;
} finally {
IOUtils.close(in);
}
}
public static String encrypt(String text) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5"); | digest.update(text.getBytes(Constants.UTF_8)); |
mpusher/mpush-client-java | src/main/java/com/mpush/client/ConnectThread.java | // Path: src/main/java/com/mpush/util/thread/EventLock.java
// public final class EventLock {
// private final ReentrantLock lock;
// private final Condition cond;
//
// public EventLock() {
// lock = new ReentrantLock();
// cond = lock.newCondition();
// }
//
// public void lock() {
// lock.lock();
// }
//
// public void unlock() {
// lock.unlock();
// }
//
// public void signal() {
// cond.signal();
// }
//
// public void signalAll() {
// cond.signalAll();
// }
//
// public void broadcast() {
// lock.lock();
// cond.signalAll();
// lock.unlock();
// }
//
// public boolean await(long timeout) {
// lock.lock();
// try {
// cond.awaitNanos(TimeUnit.MILLISECONDS.toNanos(timeout));
// } catch (InterruptedException e) {
// return true;
// } finally {
// lock.unlock();
// }
// return false;
// }
//
// public boolean await() {
// lock.lock();
// try {
// cond.await();
// } catch (InterruptedException e) {
// return true;
// } finally {
// lock.unlock();
// }
// return false;
// }
//
// public ReentrantLock getLock() {
// return lock;
// }
//
// public Condition getCond() {
// return cond;
// }
// }
//
// Path: src/main/java/com/mpush/util/thread/ExecutorManager.java
// public final class ExecutorManager {
// public static final String THREAD_NAME_PREFIX = "mp-client-";
// public static final String WRITE_THREAD_NAME = THREAD_NAME_PREFIX + "write-t";
// public static final String READ_THREAD_NAME = THREAD_NAME_PREFIX + "read-t";
// public static final String DISPATCH_THREAD_NAME = THREAD_NAME_PREFIX + "dispatch-t";
// public static final String START_THREAD_NAME = THREAD_NAME_PREFIX + "start-t";
// public static final String TIMER_THREAD_NAME = THREAD_NAME_PREFIX + "timer-t";
// public static final ExecutorManager INSTANCE = new ExecutorManager();
// private ThreadPoolExecutor writeThread;
// private ThreadPoolExecutor dispatchThread;
// private ScheduledExecutorService timerThread;
//
// public ThreadPoolExecutor getWriteThread() {
// if (writeThread == null || writeThread.isShutdown()) {
// writeThread = new ThreadPoolExecutor(1, 1,
// 0L, TimeUnit.MILLISECONDS,
// new LinkedBlockingQueue<Runnable>(100),
// new NamedThreadFactory(WRITE_THREAD_NAME),
// new RejectedHandler());
// }
// return writeThread;
// }
//
// public ThreadPoolExecutor getDispatchThread() {
// if (dispatchThread == null || dispatchThread.isShutdown()) {
// dispatchThread = new ThreadPoolExecutor(2, 4,
// 1L, TimeUnit.SECONDS,
// new LinkedBlockingQueue<Runnable>(100),
// new NamedThreadFactory(DISPATCH_THREAD_NAME),
// new RejectedHandler());
// }
// return dispatchThread;
// }
//
// public ScheduledExecutorService getTimerThread() {
// if (timerThread == null || timerThread.isShutdown()) {
// timerThread = new ScheduledThreadPoolExecutor(1,
// new NamedThreadFactory(TIMER_THREAD_NAME),
// new RejectedHandler());
// }
// return timerThread;
// }
//
// public synchronized void shutdown() {
// if (writeThread != null) {
// writeThread.shutdownNow();
// writeThread = null;
// }
// if (dispatchThread != null) {
// dispatchThread.shutdownNow();
// dispatchThread = null;
// }
// if (timerThread != null) {
// timerThread.shutdownNow();
// timerThread = null;
// }
// }
//
// public static boolean isMPThread() {
// return Thread.currentThread().getName().startsWith(THREAD_NAME_PREFIX);
// }
//
// private static class RejectedHandler implements RejectedExecutionHandler {
//
// @Override
// public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
// ClientConfig.I.getLogger().w("a task was rejected r=%s", r);
// }
// }
// }
| import java.util.concurrent.Callable;
import com.mpush.util.thread.EventLock;
import com.mpush.util.thread.ExecutorManager; | /*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.client;
/**
* Created by yxx on 2016/6/9.
*
* @author [email protected] (夜色)
*/
public class ConnectThread extends Thread {
private volatile Callable<Boolean> runningTask;
private volatile boolean runningFlag = true; | // Path: src/main/java/com/mpush/util/thread/EventLock.java
// public final class EventLock {
// private final ReentrantLock lock;
// private final Condition cond;
//
// public EventLock() {
// lock = new ReentrantLock();
// cond = lock.newCondition();
// }
//
// public void lock() {
// lock.lock();
// }
//
// public void unlock() {
// lock.unlock();
// }
//
// public void signal() {
// cond.signal();
// }
//
// public void signalAll() {
// cond.signalAll();
// }
//
// public void broadcast() {
// lock.lock();
// cond.signalAll();
// lock.unlock();
// }
//
// public boolean await(long timeout) {
// lock.lock();
// try {
// cond.awaitNanos(TimeUnit.MILLISECONDS.toNanos(timeout));
// } catch (InterruptedException e) {
// return true;
// } finally {
// lock.unlock();
// }
// return false;
// }
//
// public boolean await() {
// lock.lock();
// try {
// cond.await();
// } catch (InterruptedException e) {
// return true;
// } finally {
// lock.unlock();
// }
// return false;
// }
//
// public ReentrantLock getLock() {
// return lock;
// }
//
// public Condition getCond() {
// return cond;
// }
// }
//
// Path: src/main/java/com/mpush/util/thread/ExecutorManager.java
// public final class ExecutorManager {
// public static final String THREAD_NAME_PREFIX = "mp-client-";
// public static final String WRITE_THREAD_NAME = THREAD_NAME_PREFIX + "write-t";
// public static final String READ_THREAD_NAME = THREAD_NAME_PREFIX + "read-t";
// public static final String DISPATCH_THREAD_NAME = THREAD_NAME_PREFIX + "dispatch-t";
// public static final String START_THREAD_NAME = THREAD_NAME_PREFIX + "start-t";
// public static final String TIMER_THREAD_NAME = THREAD_NAME_PREFIX + "timer-t";
// public static final ExecutorManager INSTANCE = new ExecutorManager();
// private ThreadPoolExecutor writeThread;
// private ThreadPoolExecutor dispatchThread;
// private ScheduledExecutorService timerThread;
//
// public ThreadPoolExecutor getWriteThread() {
// if (writeThread == null || writeThread.isShutdown()) {
// writeThread = new ThreadPoolExecutor(1, 1,
// 0L, TimeUnit.MILLISECONDS,
// new LinkedBlockingQueue<Runnable>(100),
// new NamedThreadFactory(WRITE_THREAD_NAME),
// new RejectedHandler());
// }
// return writeThread;
// }
//
// public ThreadPoolExecutor getDispatchThread() {
// if (dispatchThread == null || dispatchThread.isShutdown()) {
// dispatchThread = new ThreadPoolExecutor(2, 4,
// 1L, TimeUnit.SECONDS,
// new LinkedBlockingQueue<Runnable>(100),
// new NamedThreadFactory(DISPATCH_THREAD_NAME),
// new RejectedHandler());
// }
// return dispatchThread;
// }
//
// public ScheduledExecutorService getTimerThread() {
// if (timerThread == null || timerThread.isShutdown()) {
// timerThread = new ScheduledThreadPoolExecutor(1,
// new NamedThreadFactory(TIMER_THREAD_NAME),
// new RejectedHandler());
// }
// return timerThread;
// }
//
// public synchronized void shutdown() {
// if (writeThread != null) {
// writeThread.shutdownNow();
// writeThread = null;
// }
// if (dispatchThread != null) {
// dispatchThread.shutdownNow();
// dispatchThread = null;
// }
// if (timerThread != null) {
// timerThread.shutdownNow();
// timerThread = null;
// }
// }
//
// public static boolean isMPThread() {
// return Thread.currentThread().getName().startsWith(THREAD_NAME_PREFIX);
// }
//
// private static class RejectedHandler implements RejectedExecutionHandler {
//
// @Override
// public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
// ClientConfig.I.getLogger().w("a task was rejected r=%s", r);
// }
// }
// }
// Path: src/main/java/com/mpush/client/ConnectThread.java
import java.util.concurrent.Callable;
import com.mpush.util.thread.EventLock;
import com.mpush.util.thread.ExecutorManager;
/*
* (C) Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Contributors:
* [email protected] (夜色)
*/
package com.mpush.client;
/**
* Created by yxx on 2016/6/9.
*
* @author [email protected] (夜色)
*/
public class ConnectThread extends Thread {
private volatile Callable<Boolean> runningTask;
private volatile boolean runningFlag = true; | private final EventLock connLock; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.