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
stephanrauh/BootsFaces-Examples
SPA/src/main/java/de/oc/lunch/database/example/DefaultDatabase.java
// Path: SPA/src/main/java/de/oc/lunch/database/DataBase.java // @SessionScoped // @Named // public class DataBase implements Serializable { // private static final long serialVersionUID = 1L; // // private static EntityManagerFactory emf = null; // // @Transient // private EntityManager entityManager = null; // // public EntityManagerFactory createEntityManagerFactory() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // return getEmf(); // } // // @Produces @LunchDB // public EntityManager createEntityManager() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // if (null == entityManager) { // entityManager = getEmf().createEntityManager(); // } else if (!entityManager.isOpen()) { // entityManager = getEmf().createEntityManager(); // } // return entityManager; // } // // public static EntityManagerFactory getEmf() { // return emf; // } // // public static void setEmf(EntityManagerFactory emf) { // DataBase.emf = emf; // } // // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/DeliveryServiceEntity.java // @Entity // public class DeliveryServiceEntity implements Serializable, PersistentObject<DeliveryServiceEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy=GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max=30) // private String name; // // @Size(max=100) // private String website; // // public DeliveryServiceEntity() { // } // // public DeliveryServiceEntity(String name, String website) { // this.name = name; // this.website = website; // } // // 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 getWebsite() { // return website; // } // // public void setWebsite(String website) { // this.website = website; // } // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/UserEntity.java // @Entity // @Named // @SessionScoped // public class UserEntity implements Serializable, PersistentObject<UserEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max = 30) // private String name; // // @Size(max = 100) // private String email; // // public UserEntity() { // } // // public UserEntity(String name, String email) { // this.name = name; // this.email = 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; // } // }
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.TypedQuery; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.apache.log4j.Logger; import de.oc.lunch.database.DataBase; import de.oc.lunch.persistence.DeliveryServiceEntity; import de.oc.lunch.persistence.UserEntity;
package de.oc.lunch.database.example; @WebListener public class DefaultDatabase implements ServletContextListener { private static final Logger LOGGER = Logger.getLogger(DefaultDatabase.class); @Override public void contextDestroyed(ServletContextEvent arg0) {
// Path: SPA/src/main/java/de/oc/lunch/database/DataBase.java // @SessionScoped // @Named // public class DataBase implements Serializable { // private static final long serialVersionUID = 1L; // // private static EntityManagerFactory emf = null; // // @Transient // private EntityManager entityManager = null; // // public EntityManagerFactory createEntityManagerFactory() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // return getEmf(); // } // // @Produces @LunchDB // public EntityManager createEntityManager() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // if (null == entityManager) { // entityManager = getEmf().createEntityManager(); // } else if (!entityManager.isOpen()) { // entityManager = getEmf().createEntityManager(); // } // return entityManager; // } // // public static EntityManagerFactory getEmf() { // return emf; // } // // public static void setEmf(EntityManagerFactory emf) { // DataBase.emf = emf; // } // // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/DeliveryServiceEntity.java // @Entity // public class DeliveryServiceEntity implements Serializable, PersistentObject<DeliveryServiceEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy=GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max=30) // private String name; // // @Size(max=100) // private String website; // // public DeliveryServiceEntity() { // } // // public DeliveryServiceEntity(String name, String website) { // this.name = name; // this.website = website; // } // // 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 getWebsite() { // return website; // } // // public void setWebsite(String website) { // this.website = website; // } // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/UserEntity.java // @Entity // @Named // @SessionScoped // public class UserEntity implements Serializable, PersistentObject<UserEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max = 30) // private String name; // // @Size(max = 100) // private String email; // // public UserEntity() { // } // // public UserEntity(String name, String email) { // this.name = name; // this.email = 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; // } // } // Path: SPA/src/main/java/de/oc/lunch/database/example/DefaultDatabase.java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.TypedQuery; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.apache.log4j.Logger; import de.oc.lunch.database.DataBase; import de.oc.lunch.persistence.DeliveryServiceEntity; import de.oc.lunch.persistence.UserEntity; package de.oc.lunch.database.example; @WebListener public class DefaultDatabase implements ServletContextListener { private static final Logger LOGGER = Logger.getLogger(DefaultDatabase.class); @Override public void contextDestroyed(ServletContextEvent arg0) {
DataBase.getEmf().close();
stephanrauh/BootsFaces-Examples
SPA/src/main/java/de/oc/lunch/database/example/DefaultDatabase.java
// Path: SPA/src/main/java/de/oc/lunch/database/DataBase.java // @SessionScoped // @Named // public class DataBase implements Serializable { // private static final long serialVersionUID = 1L; // // private static EntityManagerFactory emf = null; // // @Transient // private EntityManager entityManager = null; // // public EntityManagerFactory createEntityManagerFactory() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // return getEmf(); // } // // @Produces @LunchDB // public EntityManager createEntityManager() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // if (null == entityManager) { // entityManager = getEmf().createEntityManager(); // } else if (!entityManager.isOpen()) { // entityManager = getEmf().createEntityManager(); // } // return entityManager; // } // // public static EntityManagerFactory getEmf() { // return emf; // } // // public static void setEmf(EntityManagerFactory emf) { // DataBase.emf = emf; // } // // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/DeliveryServiceEntity.java // @Entity // public class DeliveryServiceEntity implements Serializable, PersistentObject<DeliveryServiceEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy=GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max=30) // private String name; // // @Size(max=100) // private String website; // // public DeliveryServiceEntity() { // } // // public DeliveryServiceEntity(String name, String website) { // this.name = name; // this.website = website; // } // // 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 getWebsite() { // return website; // } // // public void setWebsite(String website) { // this.website = website; // } // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/UserEntity.java // @Entity // @Named // @SessionScoped // public class UserEntity implements Serializable, PersistentObject<UserEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max = 30) // private String name; // // @Size(max = 100) // private String email; // // public UserEntity() { // } // // public UserEntity(String name, String email) { // this.name = name; // this.email = 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; // } // }
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.TypedQuery; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.apache.log4j.Logger; import de.oc.lunch.database.DataBase; import de.oc.lunch.persistence.DeliveryServiceEntity; import de.oc.lunch.persistence.UserEntity;
@Override public void contextInitialized(ServletContextEvent arg0) { EntityManager entityManager = new DataBase().createEntityManager(); populateUserTable(entityManager); readUserTable(entityManager); populateDeliveryServiceTable(entityManager); entityManager.close(); } public void populateUserTable(EntityManager entityManager) { EntityTransaction transaction = entityManager.getTransaction(); try { transaction.begin(); createUser(entityManager, "Robina Kuh", "robina.kuh@example.com"); createUser(entityManager, "Wayne Interessierts", "wayne.interessierts@example.com"); createUser(entityManager, "John Doe", "john.doe@example.com"); createUser(entityManager, "Jane Dull", "jane.dull@example.com"); List<String> names = Names.getNames(); for (String name:names) { createUser(entityManager, name, name.replace(" ", ".")+"@example.com"); } transaction.commit(); } catch (Exception e) { transaction.rollback(); } } public void populateDeliveryServiceTable(EntityManager entityManager) {
// Path: SPA/src/main/java/de/oc/lunch/database/DataBase.java // @SessionScoped // @Named // public class DataBase implements Serializable { // private static final long serialVersionUID = 1L; // // private static EntityManagerFactory emf = null; // // @Transient // private EntityManager entityManager = null; // // public EntityManagerFactory createEntityManagerFactory() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // return getEmf(); // } // // @Produces @LunchDB // public EntityManager createEntityManager() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // if (null == entityManager) { // entityManager = getEmf().createEntityManager(); // } else if (!entityManager.isOpen()) { // entityManager = getEmf().createEntityManager(); // } // return entityManager; // } // // public static EntityManagerFactory getEmf() { // return emf; // } // // public static void setEmf(EntityManagerFactory emf) { // DataBase.emf = emf; // } // // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/DeliveryServiceEntity.java // @Entity // public class DeliveryServiceEntity implements Serializable, PersistentObject<DeliveryServiceEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy=GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max=30) // private String name; // // @Size(max=100) // private String website; // // public DeliveryServiceEntity() { // } // // public DeliveryServiceEntity(String name, String website) { // this.name = name; // this.website = website; // } // // 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 getWebsite() { // return website; // } // // public void setWebsite(String website) { // this.website = website; // } // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/UserEntity.java // @Entity // @Named // @SessionScoped // public class UserEntity implements Serializable, PersistentObject<UserEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max = 30) // private String name; // // @Size(max = 100) // private String email; // // public UserEntity() { // } // // public UserEntity(String name, String email) { // this.name = name; // this.email = 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; // } // } // Path: SPA/src/main/java/de/oc/lunch/database/example/DefaultDatabase.java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.TypedQuery; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.apache.log4j.Logger; import de.oc.lunch.database.DataBase; import de.oc.lunch.persistence.DeliveryServiceEntity; import de.oc.lunch.persistence.UserEntity; @Override public void contextInitialized(ServletContextEvent arg0) { EntityManager entityManager = new DataBase().createEntityManager(); populateUserTable(entityManager); readUserTable(entityManager); populateDeliveryServiceTable(entityManager); entityManager.close(); } public void populateUserTable(EntityManager entityManager) { EntityTransaction transaction = entityManager.getTransaction(); try { transaction.begin(); createUser(entityManager, "Robina Kuh", "robina.kuh@example.com"); createUser(entityManager, "Wayne Interessierts", "wayne.interessierts@example.com"); createUser(entityManager, "John Doe", "john.doe@example.com"); createUser(entityManager, "Jane Dull", "jane.dull@example.com"); List<String> names = Names.getNames(); for (String name:names) { createUser(entityManager, name, name.replace(" ", ".")+"@example.com"); } transaction.commit(); } catch (Exception e) { transaction.rollback(); } } public void populateDeliveryServiceTable(EntityManager entityManager) {
DeliveryServiceEntity service = new DeliveryServiceEntity("Lieferheld", "www.lieferheld.de");
stephanrauh/BootsFaces-Examples
SPA/src/main/java/de/oc/lunch/database/example/DefaultDatabase.java
// Path: SPA/src/main/java/de/oc/lunch/database/DataBase.java // @SessionScoped // @Named // public class DataBase implements Serializable { // private static final long serialVersionUID = 1L; // // private static EntityManagerFactory emf = null; // // @Transient // private EntityManager entityManager = null; // // public EntityManagerFactory createEntityManagerFactory() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // return getEmf(); // } // // @Produces @LunchDB // public EntityManager createEntityManager() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // if (null == entityManager) { // entityManager = getEmf().createEntityManager(); // } else if (!entityManager.isOpen()) { // entityManager = getEmf().createEntityManager(); // } // return entityManager; // } // // public static EntityManagerFactory getEmf() { // return emf; // } // // public static void setEmf(EntityManagerFactory emf) { // DataBase.emf = emf; // } // // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/DeliveryServiceEntity.java // @Entity // public class DeliveryServiceEntity implements Serializable, PersistentObject<DeliveryServiceEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy=GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max=30) // private String name; // // @Size(max=100) // private String website; // // public DeliveryServiceEntity() { // } // // public DeliveryServiceEntity(String name, String website) { // this.name = name; // this.website = website; // } // // 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 getWebsite() { // return website; // } // // public void setWebsite(String website) { // this.website = website; // } // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/UserEntity.java // @Entity // @Named // @SessionScoped // public class UserEntity implements Serializable, PersistentObject<UserEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max = 30) // private String name; // // @Size(max = 100) // private String email; // // public UserEntity() { // } // // public UserEntity(String name, String email) { // this.name = name; // this.email = 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; // } // }
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.TypedQuery; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.apache.log4j.Logger; import de.oc.lunch.database.DataBase; import de.oc.lunch.persistence.DeliveryServiceEntity; import de.oc.lunch.persistence.UserEntity;
EntityTransaction transaction = entityManager.getTransaction(); try { transaction.begin(); createUser(entityManager, "Robina Kuh", "robina.kuh@example.com"); createUser(entityManager, "Wayne Interessierts", "wayne.interessierts@example.com"); createUser(entityManager, "John Doe", "john.doe@example.com"); createUser(entityManager, "Jane Dull", "jane.dull@example.com"); List<String> names = Names.getNames(); for (String name:names) { createUser(entityManager, name, name.replace(" ", ".")+"@example.com"); } transaction.commit(); } catch (Exception e) { transaction.rollback(); } } public void populateDeliveryServiceTable(EntityManager entityManager) { DeliveryServiceEntity service = new DeliveryServiceEntity("Lieferheld", "www.lieferheld.de"); service.persist(entityManager); service = new DeliveryServiceEntity("BeyondJava", "www.beyondjava.net"); service.persist(entityManager); if (false) { List<DeliveryServiceEntity> services = new DeliveryServiceEntity().findAll(entityManager); LOGGER.info(services.size()); } } public void readUserTable(EntityManager entityManager) {
// Path: SPA/src/main/java/de/oc/lunch/database/DataBase.java // @SessionScoped // @Named // public class DataBase implements Serializable { // private static final long serialVersionUID = 1L; // // private static EntityManagerFactory emf = null; // // @Transient // private EntityManager entityManager = null; // // public EntityManagerFactory createEntityManagerFactory() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // return getEmf(); // } // // @Produces @LunchDB // public EntityManager createEntityManager() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // if (null == entityManager) { // entityManager = getEmf().createEntityManager(); // } else if (!entityManager.isOpen()) { // entityManager = getEmf().createEntityManager(); // } // return entityManager; // } // // public static EntityManagerFactory getEmf() { // return emf; // } // // public static void setEmf(EntityManagerFactory emf) { // DataBase.emf = emf; // } // // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/DeliveryServiceEntity.java // @Entity // public class DeliveryServiceEntity implements Serializable, PersistentObject<DeliveryServiceEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy=GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max=30) // private String name; // // @Size(max=100) // private String website; // // public DeliveryServiceEntity() { // } // // public DeliveryServiceEntity(String name, String website) { // this.name = name; // this.website = website; // } // // 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 getWebsite() { // return website; // } // // public void setWebsite(String website) { // this.website = website; // } // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/UserEntity.java // @Entity // @Named // @SessionScoped // public class UserEntity implements Serializable, PersistentObject<UserEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max = 30) // private String name; // // @Size(max = 100) // private String email; // // public UserEntity() { // } // // public UserEntity(String name, String email) { // this.name = name; // this.email = 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; // } // } // Path: SPA/src/main/java/de/oc/lunch/database/example/DefaultDatabase.java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.TypedQuery; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.apache.log4j.Logger; import de.oc.lunch.database.DataBase; import de.oc.lunch.persistence.DeliveryServiceEntity; import de.oc.lunch.persistence.UserEntity; EntityTransaction transaction = entityManager.getTransaction(); try { transaction.begin(); createUser(entityManager, "Robina Kuh", "robina.kuh@example.com"); createUser(entityManager, "Wayne Interessierts", "wayne.interessierts@example.com"); createUser(entityManager, "John Doe", "john.doe@example.com"); createUser(entityManager, "Jane Dull", "jane.dull@example.com"); List<String> names = Names.getNames(); for (String name:names) { createUser(entityManager, name, name.replace(" ", ".")+"@example.com"); } transaction.commit(); } catch (Exception e) { transaction.rollback(); } } public void populateDeliveryServiceTable(EntityManager entityManager) { DeliveryServiceEntity service = new DeliveryServiceEntity("Lieferheld", "www.lieferheld.de"); service.persist(entityManager); service = new DeliveryServiceEntity("BeyondJava", "www.beyondjava.net"); service.persist(entityManager); if (false) { List<DeliveryServiceEntity> services = new DeliveryServiceEntity().findAll(entityManager); LOGGER.info(services.size()); } } public void readUserTable(EntityManager entityManager) {
TypedQuery<UserEntity> query = entityManager.createQuery("from UserEntity", UserEntity.class);
stephanrauh/BootsFaces-Examples
BootsFacesChess/src/main/java/de/beyondjava/bootsfaces/chess/objectOrientedEngine/XMove.java
// Path: BootsFacesChess/src/main/java/de/beyondjava/bootsfaces/chess/common/Move.java // public class Move implements Comparable<Move> { // public int fromColumn; // public int fromRow; // public int toColumn; // public int toRow; // public int materialValueAfterMove; // public boolean opponentInCheck; // public int positionalValue = 0; // public boolean capture; // public int piece; // public int capturedPiece; // public int boardAfterMove; // used by PrimitiveMoveGenerator // public int moveValue; // value of the board after the move, according to the possible moves // // public Move(int piece, int fromRow, int fromColumn, int toRow, int toColumn, int materialValueAfterMove, boolean opponentInCheck, boolean capture, int capturedPiece) { // this.piece = piece; // this.fromColumn = fromColumn; // this.fromRow = fromRow; // this.toRow = toRow; // this.toColumn = toColumn; // this.materialValueAfterMove = materialValueAfterMove; // this.opponentInCheck = opponentInCheck; // this.capture = capture; // this.capturedPiece = capturedPiece; // } // // @Override // public int compareTo(Move o) { // if (null == o) return -1; // int m = o.materialValueAfterMove - materialValueAfterMove; // int p = o.positionalValue - positionalValue; // return -(m + p); // } // // public String getNotation() { // return getNotation(false); // } // // public String getNotation(boolean enPassant) { // String check = opponentInCheck ? "+" : " "; // String s = capture ? "x" : "-"; // s += PIECE_NAME[capturedPiece + 1]; // if (piece==W_KING && fromRow==7 && toRow==7 && fromColumn==4 && toColumn==6) // { // return "0-0"; // } // if (piece==W_KING && fromRow==7 && toRow==7 && fromColumn==4 && toColumn==2) // { // return "0-0-0"; // } // if (piece==B_KING && fromRow==0 && toRow==0 && fromColumn==4 && toColumn==6) // { // return "0-0"; // } // if (piece==B_KING && fromRow==0 && toRow==0 && fromColumn==4 && toColumn==2) // { // return "0-0-0"; // } // String ep=enPassant?"e.p.":""; // // return PIECE_NAME[piece + 1] + COLUMNS[fromColumn] + ROWS[fromRow] + s + COLUMNS[toColumn] + ROWS[toRow] + ep + check; // } // // public String toString() { // String m = String.format("%5d", materialValueAfterMove); // String p = String.format("%5d", positionalValue); // String mv = String.format("%5d", moveValue); // String s = String.format("%5d", materialValueAfterMove + positionalValue + moveValue); // return getNotation() + " Value: M: " + m + " P: " + p + " Mv:" + mv + " Sum: " + s; // } // }
import de.beyondjava.bootsfaces.chess.common.Move;
public int blackPotentialMaterialValue; public int whiteFieldPositionValue; public int blackFieldPositionValue; public int whiteMoveValue; public int blackMoveValue; public int whiteCoverageValue; public int blackCoverageValue; public boolean isWhiteKingThreatened; public boolean isBlackKingThreatened; public int whiteTotalValue; public int blackTotalValue; public int numberOfWhiteMoves; public int numberOfBlackMoves ; public int piece; public Chessboard boardAfterMove; public boolean stalemate; public boolean checkmate; @Override public int compareTo(XMove o) { return (whiteTotalValue-blackTotalValue) - (o.whiteTotalValue-o.blackTotalValue); } public String getNotation() { int fromRow = (move >> 12) & 0x000F; int fromColumn = (move >> 8) & 0x000F; int toRow = (move >> 4) & 0x000F; int toColumn = move & 0x000F; boolean capture = (move >> 24)>0;
// Path: BootsFacesChess/src/main/java/de/beyondjava/bootsfaces/chess/common/Move.java // public class Move implements Comparable<Move> { // public int fromColumn; // public int fromRow; // public int toColumn; // public int toRow; // public int materialValueAfterMove; // public boolean opponentInCheck; // public int positionalValue = 0; // public boolean capture; // public int piece; // public int capturedPiece; // public int boardAfterMove; // used by PrimitiveMoveGenerator // public int moveValue; // value of the board after the move, according to the possible moves // // public Move(int piece, int fromRow, int fromColumn, int toRow, int toColumn, int materialValueAfterMove, boolean opponentInCheck, boolean capture, int capturedPiece) { // this.piece = piece; // this.fromColumn = fromColumn; // this.fromRow = fromRow; // this.toRow = toRow; // this.toColumn = toColumn; // this.materialValueAfterMove = materialValueAfterMove; // this.opponentInCheck = opponentInCheck; // this.capture = capture; // this.capturedPiece = capturedPiece; // } // // @Override // public int compareTo(Move o) { // if (null == o) return -1; // int m = o.materialValueAfterMove - materialValueAfterMove; // int p = o.positionalValue - positionalValue; // return -(m + p); // } // // public String getNotation() { // return getNotation(false); // } // // public String getNotation(boolean enPassant) { // String check = opponentInCheck ? "+" : " "; // String s = capture ? "x" : "-"; // s += PIECE_NAME[capturedPiece + 1]; // if (piece==W_KING && fromRow==7 && toRow==7 && fromColumn==4 && toColumn==6) // { // return "0-0"; // } // if (piece==W_KING && fromRow==7 && toRow==7 && fromColumn==4 && toColumn==2) // { // return "0-0-0"; // } // if (piece==B_KING && fromRow==0 && toRow==0 && fromColumn==4 && toColumn==6) // { // return "0-0"; // } // if (piece==B_KING && fromRow==0 && toRow==0 && fromColumn==4 && toColumn==2) // { // return "0-0-0"; // } // String ep=enPassant?"e.p.":""; // // return PIECE_NAME[piece + 1] + COLUMNS[fromColumn] + ROWS[fromRow] + s + COLUMNS[toColumn] + ROWS[toRow] + ep + check; // } // // public String toString() { // String m = String.format("%5d", materialValueAfterMove); // String p = String.format("%5d", positionalValue); // String mv = String.format("%5d", moveValue); // String s = String.format("%5d", materialValueAfterMove + positionalValue + moveValue); // return getNotation() + " Value: M: " + m + " P: " + p + " Mv:" + mv + " Sum: " + s; // } // } // Path: BootsFacesChess/src/main/java/de/beyondjava/bootsfaces/chess/objectOrientedEngine/XMove.java import de.beyondjava.bootsfaces.chess.common.Move; public int blackPotentialMaterialValue; public int whiteFieldPositionValue; public int blackFieldPositionValue; public int whiteMoveValue; public int blackMoveValue; public int whiteCoverageValue; public int blackCoverageValue; public boolean isWhiteKingThreatened; public boolean isBlackKingThreatened; public int whiteTotalValue; public int blackTotalValue; public int numberOfWhiteMoves; public int numberOfBlackMoves ; public int piece; public Chessboard boardAfterMove; public boolean stalemate; public boolean checkmate; @Override public int compareTo(XMove o) { return (whiteTotalValue-blackTotalValue) - (o.whiteTotalValue-o.blackTotalValue); } public String getNotation() { int fromRow = (move >> 12) & 0x000F; int fromColumn = (move >> 8) & 0x000F; int toRow = (move >> 4) & 0x000F; int toColumn = move & 0x000F; boolean capture = (move >> 24)>0;
Move m = new Move(piece, fromRow, fromColumn, toRow, toColumn, 0, false, capture, 0 );
stephanrauh/BootsFaces-Examples
SPA/src/main/java/de/oc/lunch/controller/UserBean.java
// Path: SPA/src/main/java/de/oc/lunch/database/DataBase.java // @SessionScoped // @Named // public class DataBase implements Serializable { // private static final long serialVersionUID = 1L; // // private static EntityManagerFactory emf = null; // // @Transient // private EntityManager entityManager = null; // // public EntityManagerFactory createEntityManagerFactory() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // return getEmf(); // } // // @Produces @LunchDB // public EntityManager createEntityManager() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // if (null == entityManager) { // entityManager = getEmf().createEntityManager(); // } else if (!entityManager.isOpen()) { // entityManager = getEmf().createEntityManager(); // } // return entityManager; // } // // public static EntityManagerFactory getEmf() { // return emf; // } // // public static void setEmf(EntityManagerFactory emf) { // DataBase.emf = emf; // } // // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/UserEntity.java // @Entity // @Named // @SessionScoped // public class UserEntity implements Serializable, PersistentObject<UserEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max = 30) // private String name; // // @Size(max = 100) // private String email; // // public UserEntity() { // } // // public UserEntity(String name, String email) { // this.name = name; // this.email = 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; // } // }
import java.io.Serializable; import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; import javax.inject.Inject; import javax.inject.Named; import javax.persistence.Entity; import javax.persistence.EntityManager; import de.oc.lunch.database.DataBase; import de.oc.lunch.database.LunchDB; import de.oc.lunch.persistence.UserEntity;
package de.oc.lunch.controller; @Named @SessionScoped public class UserBean implements Serializable { private static final long serialVersionUID = 1L; @Inject @LunchDB private EntityManager entityManager = null;
// Path: SPA/src/main/java/de/oc/lunch/database/DataBase.java // @SessionScoped // @Named // public class DataBase implements Serializable { // private static final long serialVersionUID = 1L; // // private static EntityManagerFactory emf = null; // // @Transient // private EntityManager entityManager = null; // // public EntityManagerFactory createEntityManagerFactory() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // return getEmf(); // } // // @Produces @LunchDB // public EntityManager createEntityManager() { // if (null == getEmf()) { // setEmf(Persistence.createEntityManagerFactory("lunch")); // } // if (null == entityManager) { // entityManager = getEmf().createEntityManager(); // } else if (!entityManager.isOpen()) { // entityManager = getEmf().createEntityManager(); // } // return entityManager; // } // // public static EntityManagerFactory getEmf() { // return emf; // } // // public static void setEmf(EntityManagerFactory emf) { // DataBase.emf = emf; // } // // } // // Path: SPA/src/main/java/de/oc/lunch/persistence/UserEntity.java // @Entity // @Named // @SessionScoped // public class UserEntity implements Serializable, PersistentObject<UserEntity> { // private static final long serialVersionUID = 1L; // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private long id; // = UUID.randomUUID().getLeastSignificantBits(); // // @Size(max = 30) // private String name; // // @Size(max = 100) // private String email; // // public UserEntity() { // } // // public UserEntity(String name, String email) { // this.name = name; // this.email = 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; // } // } // Path: SPA/src/main/java/de/oc/lunch/controller/UserBean.java import java.io.Serializable; import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; import javax.inject.Inject; import javax.inject.Named; import javax.persistence.Entity; import javax.persistence.EntityManager; import de.oc.lunch.database.DataBase; import de.oc.lunch.database.LunchDB; import de.oc.lunch.persistence.UserEntity; package de.oc.lunch.controller; @Named @SessionScoped public class UserBean implements Serializable { private static final long serialVersionUID = 1L; @Inject @LunchDB private EntityManager entityManager = null;
private UserEntity filter = new UserEntity();
cmusatyalab/faceswap
android-client/app/src/main/java/edu/cmu/cs/utils/NetworkUtils.java
// Path: android-client/app/src/main/java/edu/cmu/cs/gabriel/Const.java // public class Const { // /* // * Experiement variable // */ // // public static final boolean IS_EXPERIMENT = false; // public static final boolean USE_JPEG_COMPRESSION = true; // // // // Transfer from the file list // // If TEST_IMAGE_DIR is not none, transmit from the image // public static File ROOT_DIR = new File(Environment.getExternalStorageDirectory() + File.separator + "Gabriel" + File.separator); // public static File TEST_IMAGE_DIR = new File (ROOT_DIR.getAbsolutePath() + File.separator + "images" + File.separator); // // // control VM // public static String GABRIEL_IP = "128.2.213.107"; // Cloudlet by default // // public static String GABRIEL_IP = "54.201.173.207"; // Amazon West // public static String CLOUDLET_GABRIEL_IP = "128.2.213.107"; // Cloudlet // // public static String CLOUDLET_GABRIEL_IP = "128.2.13.107"; // Cloudlet // // public static String CLOUD_GABRIEL_IP = "54.200.101.84"; // Amazon West // public static String CLOUD_GABRIEL_IP = "54.189.165.75"; // Amazon West // // // Token // public static int MAX_TOKEN_SIZE = 1; // // // image size and frame rate // public static int MIN_FPS = 10; // public static int IMAGE_WIDTH = 640; // public static int IMAGE_HEIGHT = 480; // //640x480 // //800x600 // //1024x960 // // // Result File // public static String LATENCY_FILE_NAME = "latency-" + GABRIEL_IP + "-" + MAX_TOKEN_SIZE + ".txt"; // public static File LATENCY_DIR = new File(ROOT_DIR.getAbsolutePath() + File.separator + "exp"); // public static File LATENCY_FILE = new File (LATENCY_DIR.getAbsolutePath() + File.separator + LATENCY_FILE_NAME); // // //result type: one-hot // public static boolean RESPONSE_ENCODED_IMG=false; // public static boolean RESPONSE_ROI_FACE_SNIPPET=false; // public static boolean RESPONSE_JSON=true; // // //display preview or img processed from gabriel server // public static boolean DISPLAY_PREVIEW_ONLY=false; // // public static final String GABRIEL_CONFIGURATION_SYNC_STATE="syncState"; // public static final String GABRIEL_CONFIGURATION_DOWNLOAD_STATE="downloadState"; // public static final String GABRIEL_CONFIGURATION_DOWNLOAD_STATE_TO_GDRIVE = // "downloadStateToGdrive"; // public static final String GABRIEL_CONFIGURATION_UPLOAD_STATE="uploadState"; // public static final String GABRIEL_CONFIGURATION_RESET_STATE="reset"; // public static final String GABRIEL_CONFIGURATION_REMOVE_PERSON="remove_person"; // public static final String GABRIEL_CONFIGURATION_GET_PERSON="get_person"; // // // public static boolean FACE_DEMO_BOUNDING_BOX_ONLY=false; // //true: use the face snippets received in the packet // //false: use the bx received to crop current frame // public static boolean FACE_DEMO_DISPLAY_RECEIVED_FACES=true; // // public static String CONNECTIVITY_NOT_AVAILABLE = "Not Connected to the Internet. Please enable " + // "network connections first."; // // //save openface state file // public static String FILE_ROOT_PATH = "OpenFaceState"; // public static String OPENFACE_STATE_FILE_MAGIC_SEQUENCE="OpenFaceStateSequence\n"; // // public static boolean MEASURE_LATENCY=true; // }
import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import edu.cmu.cs.gabriel.Const; import static edu.cmu.cs.CustomExceptions.CustomExceptions.notifyError;
package edu.cmu.cs.utils; /** * Created by junjuew on 3/3/16. */ public class NetworkUtils { protected static final String IPV4Pattern = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])"; protected static final String IPV6Pattern = "([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}"; public static boolean isOnline(Context m) { ConnectivityManager connMgr = (ConnectivityManager) m.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null && networkInfo.isConnected()); } public static boolean isIpAddress(String ipAddress) { if (ipAddress.matches(IPV4Pattern) || ipAddress.matches(IPV6Pattern)) { return true; } return false; } public static boolean checkOnline(Activity a){ if (isOnline(a)) { return true; }
// Path: android-client/app/src/main/java/edu/cmu/cs/gabriel/Const.java // public class Const { // /* // * Experiement variable // */ // // public static final boolean IS_EXPERIMENT = false; // public static final boolean USE_JPEG_COMPRESSION = true; // // // // Transfer from the file list // // If TEST_IMAGE_DIR is not none, transmit from the image // public static File ROOT_DIR = new File(Environment.getExternalStorageDirectory() + File.separator + "Gabriel" + File.separator); // public static File TEST_IMAGE_DIR = new File (ROOT_DIR.getAbsolutePath() + File.separator + "images" + File.separator); // // // control VM // public static String GABRIEL_IP = "128.2.213.107"; // Cloudlet by default // // public static String GABRIEL_IP = "54.201.173.207"; // Amazon West // public static String CLOUDLET_GABRIEL_IP = "128.2.213.107"; // Cloudlet // // public static String CLOUDLET_GABRIEL_IP = "128.2.13.107"; // Cloudlet // // public static String CLOUD_GABRIEL_IP = "54.200.101.84"; // Amazon West // public static String CLOUD_GABRIEL_IP = "54.189.165.75"; // Amazon West // // // Token // public static int MAX_TOKEN_SIZE = 1; // // // image size and frame rate // public static int MIN_FPS = 10; // public static int IMAGE_WIDTH = 640; // public static int IMAGE_HEIGHT = 480; // //640x480 // //800x600 // //1024x960 // // // Result File // public static String LATENCY_FILE_NAME = "latency-" + GABRIEL_IP + "-" + MAX_TOKEN_SIZE + ".txt"; // public static File LATENCY_DIR = new File(ROOT_DIR.getAbsolutePath() + File.separator + "exp"); // public static File LATENCY_FILE = new File (LATENCY_DIR.getAbsolutePath() + File.separator + LATENCY_FILE_NAME); // // //result type: one-hot // public static boolean RESPONSE_ENCODED_IMG=false; // public static boolean RESPONSE_ROI_FACE_SNIPPET=false; // public static boolean RESPONSE_JSON=true; // // //display preview or img processed from gabriel server // public static boolean DISPLAY_PREVIEW_ONLY=false; // // public static final String GABRIEL_CONFIGURATION_SYNC_STATE="syncState"; // public static final String GABRIEL_CONFIGURATION_DOWNLOAD_STATE="downloadState"; // public static final String GABRIEL_CONFIGURATION_DOWNLOAD_STATE_TO_GDRIVE = // "downloadStateToGdrive"; // public static final String GABRIEL_CONFIGURATION_UPLOAD_STATE="uploadState"; // public static final String GABRIEL_CONFIGURATION_RESET_STATE="reset"; // public static final String GABRIEL_CONFIGURATION_REMOVE_PERSON="remove_person"; // public static final String GABRIEL_CONFIGURATION_GET_PERSON="get_person"; // // // public static boolean FACE_DEMO_BOUNDING_BOX_ONLY=false; // //true: use the face snippets received in the packet // //false: use the bx received to crop current frame // public static boolean FACE_DEMO_DISPLAY_RECEIVED_FACES=true; // // public static String CONNECTIVITY_NOT_AVAILABLE = "Not Connected to the Internet. Please enable " + // "network connections first."; // // //save openface state file // public static String FILE_ROOT_PATH = "OpenFaceState"; // public static String OPENFACE_STATE_FILE_MAGIC_SEQUENCE="OpenFaceStateSequence\n"; // // public static boolean MEASURE_LATENCY=true; // } // Path: android-client/app/src/main/java/edu/cmu/cs/utils/NetworkUtils.java import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import edu.cmu.cs.gabriel.Const; import static edu.cmu.cs.CustomExceptions.CustomExceptions.notifyError; package edu.cmu.cs.utils; /** * Created by junjuew on 3/3/16. */ public class NetworkUtils { protected static final String IPV4Pattern = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])"; protected static final String IPV6Pattern = "([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}"; public static boolean isOnline(Context m) { ConnectivityManager connMgr = (ConnectivityManager) m.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null && networkInfo.isConnected()); } public static boolean isIpAddress(String ipAddress) { if (ipAddress.matches(IPV4Pattern) || ipAddress.matches(IPV6Pattern)) { return true; } return false; } public static boolean checkOnline(Activity a){ if (isOnline(a)) { return true; }
notifyError(Const.CONNECTIVITY_NOT_AVAILABLE, false, a);
cmusatyalab/faceswap
android-client/app/src/main/java/edu/cmu/cs/gabriel/network/ResultReceivingThread.java
// Path: android-client/app/src/main/java/edu/cmu/cs/gabriel/Const.java // public class Const { // /* // * Experiement variable // */ // // public static final boolean IS_EXPERIMENT = false; // public static final boolean USE_JPEG_COMPRESSION = true; // // // // Transfer from the file list // // If TEST_IMAGE_DIR is not none, transmit from the image // public static File ROOT_DIR = new File(Environment.getExternalStorageDirectory() + File.separator + "Gabriel" + File.separator); // public static File TEST_IMAGE_DIR = new File (ROOT_DIR.getAbsolutePath() + File.separator + "images" + File.separator); // // // control VM // public static String GABRIEL_IP = "128.2.213.107"; // Cloudlet by default // // public static String GABRIEL_IP = "54.201.173.207"; // Amazon West // public static String CLOUDLET_GABRIEL_IP = "128.2.213.107"; // Cloudlet // // public static String CLOUDLET_GABRIEL_IP = "128.2.13.107"; // Cloudlet // // public static String CLOUD_GABRIEL_IP = "54.200.101.84"; // Amazon West // public static String CLOUD_GABRIEL_IP = "54.189.165.75"; // Amazon West // // // Token // public static int MAX_TOKEN_SIZE = 1; // // // image size and frame rate // public static int MIN_FPS = 10; // public static int IMAGE_WIDTH = 640; // public static int IMAGE_HEIGHT = 480; // //640x480 // //800x600 // //1024x960 // // // Result File // public static String LATENCY_FILE_NAME = "latency-" + GABRIEL_IP + "-" + MAX_TOKEN_SIZE + ".txt"; // public static File LATENCY_DIR = new File(ROOT_DIR.getAbsolutePath() + File.separator + "exp"); // public static File LATENCY_FILE = new File (LATENCY_DIR.getAbsolutePath() + File.separator + LATENCY_FILE_NAME); // // //result type: one-hot // public static boolean RESPONSE_ENCODED_IMG=false; // public static boolean RESPONSE_ROI_FACE_SNIPPET=false; // public static boolean RESPONSE_JSON=true; // // //display preview or img processed from gabriel server // public static boolean DISPLAY_PREVIEW_ONLY=false; // // public static final String GABRIEL_CONFIGURATION_SYNC_STATE="syncState"; // public static final String GABRIEL_CONFIGURATION_DOWNLOAD_STATE="downloadState"; // public static final String GABRIEL_CONFIGURATION_DOWNLOAD_STATE_TO_GDRIVE = // "downloadStateToGdrive"; // public static final String GABRIEL_CONFIGURATION_UPLOAD_STATE="uploadState"; // public static final String GABRIEL_CONFIGURATION_RESET_STATE="reset"; // public static final String GABRIEL_CONFIGURATION_REMOVE_PERSON="remove_person"; // public static final String GABRIEL_CONFIGURATION_GET_PERSON="get_person"; // // // public static boolean FACE_DEMO_BOUNDING_BOX_ONLY=false; // //true: use the face snippets received in the packet // //false: use the bx received to crop current frame // public static boolean FACE_DEMO_DISPLAY_RECEIVED_FACES=true; // // public static String CONNECTIVITY_NOT_AVAILABLE = "Not Connected to the Internet. Please enable " + // "network connections first."; // // //save openface state file // public static String FILE_ROOT_PATH = "OpenFaceState"; // public static String OPENFACE_STATE_FILE_MAGIC_SEQUENCE="OpenFaceStateSequence\n"; // // public static boolean MEASURE_LATENCY=true; // }
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.HashMap; import java.util.TreeMap; import java.util.Vector; import org.json.JSONException; import org.json.JSONObject; import edu.cmu.cs.gabriel.Const; import edu.cmu.cs.gabriel.token.TokenController; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log;
package edu.cmu.cs.gabriel.network; public class ResultReceivingThread extends Thread { private static final String LOG_TAG = "krha"; private InetAddress remoteIP; private int remotePort; private Socket tcpSocket; private boolean is_running = true; private DataOutputStream networkWriter; private DataInputStream networkReader; private Handler returnMsgHandler; private TokenController tokenController; private String connection_failure_msg = "Connecting to Gabriel Server Failed. " +
// Path: android-client/app/src/main/java/edu/cmu/cs/gabriel/Const.java // public class Const { // /* // * Experiement variable // */ // // public static final boolean IS_EXPERIMENT = false; // public static final boolean USE_JPEG_COMPRESSION = true; // // // // Transfer from the file list // // If TEST_IMAGE_DIR is not none, transmit from the image // public static File ROOT_DIR = new File(Environment.getExternalStorageDirectory() + File.separator + "Gabriel" + File.separator); // public static File TEST_IMAGE_DIR = new File (ROOT_DIR.getAbsolutePath() + File.separator + "images" + File.separator); // // // control VM // public static String GABRIEL_IP = "128.2.213.107"; // Cloudlet by default // // public static String GABRIEL_IP = "54.201.173.207"; // Amazon West // public static String CLOUDLET_GABRIEL_IP = "128.2.213.107"; // Cloudlet // // public static String CLOUDLET_GABRIEL_IP = "128.2.13.107"; // Cloudlet // // public static String CLOUD_GABRIEL_IP = "54.200.101.84"; // Amazon West // public static String CLOUD_GABRIEL_IP = "54.189.165.75"; // Amazon West // // // Token // public static int MAX_TOKEN_SIZE = 1; // // // image size and frame rate // public static int MIN_FPS = 10; // public static int IMAGE_WIDTH = 640; // public static int IMAGE_HEIGHT = 480; // //640x480 // //800x600 // //1024x960 // // // Result File // public static String LATENCY_FILE_NAME = "latency-" + GABRIEL_IP + "-" + MAX_TOKEN_SIZE + ".txt"; // public static File LATENCY_DIR = new File(ROOT_DIR.getAbsolutePath() + File.separator + "exp"); // public static File LATENCY_FILE = new File (LATENCY_DIR.getAbsolutePath() + File.separator + LATENCY_FILE_NAME); // // //result type: one-hot // public static boolean RESPONSE_ENCODED_IMG=false; // public static boolean RESPONSE_ROI_FACE_SNIPPET=false; // public static boolean RESPONSE_JSON=true; // // //display preview or img processed from gabriel server // public static boolean DISPLAY_PREVIEW_ONLY=false; // // public static final String GABRIEL_CONFIGURATION_SYNC_STATE="syncState"; // public static final String GABRIEL_CONFIGURATION_DOWNLOAD_STATE="downloadState"; // public static final String GABRIEL_CONFIGURATION_DOWNLOAD_STATE_TO_GDRIVE = // "downloadStateToGdrive"; // public static final String GABRIEL_CONFIGURATION_UPLOAD_STATE="uploadState"; // public static final String GABRIEL_CONFIGURATION_RESET_STATE="reset"; // public static final String GABRIEL_CONFIGURATION_REMOVE_PERSON="remove_person"; // public static final String GABRIEL_CONFIGURATION_GET_PERSON="get_person"; // // // public static boolean FACE_DEMO_BOUNDING_BOX_ONLY=false; // //true: use the face snippets received in the packet // //false: use the bx received to crop current frame // public static boolean FACE_DEMO_DISPLAY_RECEIVED_FACES=true; // // public static String CONNECTIVITY_NOT_AVAILABLE = "Not Connected to the Internet. Please enable " + // "network connections first."; // // //save openface state file // public static String FILE_ROOT_PATH = "OpenFaceState"; // public static String OPENFACE_STATE_FILE_MAGIC_SEQUENCE="OpenFaceStateSequence\n"; // // public static boolean MEASURE_LATENCY=true; // } // Path: android-client/app/src/main/java/edu/cmu/cs/gabriel/network/ResultReceivingThread.java import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.HashMap; import java.util.TreeMap; import java.util.Vector; import org.json.JSONException; import org.json.JSONObject; import edu.cmu.cs.gabriel.Const; import edu.cmu.cs.gabriel.token.TokenController; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; package edu.cmu.cs.gabriel.network; public class ResultReceivingThread extends Thread { private static final String LOG_TAG = "krha"; private InetAddress remoteIP; private int remotePort; private Socket tcpSocket; private boolean is_running = true; private DataOutputStream networkWriter; private DataInputStream networkReader; private Handler returnMsgHandler; private TokenController tokenController; private String connection_failure_msg = "Connecting to Gabriel Server Failed. " +
"Do you have a gabriel server running at: " + Const.GABRIEL_IP + "?";
cmusatyalab/faceswap
android-client/app/src/main/java/filepickerlibrary/FilePickerBuilder.java
// Path: android-client/app/src/main/java/filepickerlibrary/enums/MimeType.java // public enum MimeType { // JPEG("image/jpeg"), PNG("image/png"), XML("application/xml"), // XLS("application/vnd.ms-excel"), XLSX("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), // DOC("application/msword"), DOCX("application/vnd.openxmlformats-officedocument.wordprocessingml.document"), // HTML("text/html"), TXT("text/plain"), PDF("application/pdf"); // // private final String mMimeType; // // MimeType(String mimeType) { // mMimeType = mimeType; // } // // public String getMimeType() { // return mMimeType; // } // }
import android.app.Activity; import android.content.Context; import android.content.Intent; import android.support.annotation.ColorRes; import filepickerlibrary.enums.MimeType; import filepickerlibrary.enums.Request; import filepickerlibrary.enums.Scope;
package filepickerlibrary; /** * Created by Paul on 11/23/2015. */ public class FilePickerBuilder { private final Context mContext; private boolean useMaterial; private Scope mScope = Scope.ALL; private Request requestCode = Request.FILE; private int color = android.R.color.holo_blue_bright;
// Path: android-client/app/src/main/java/filepickerlibrary/enums/MimeType.java // public enum MimeType { // JPEG("image/jpeg"), PNG("image/png"), XML("application/xml"), // XLS("application/vnd.ms-excel"), XLSX("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), // DOC("application/msword"), DOCX("application/vnd.openxmlformats-officedocument.wordprocessingml.document"), // HTML("text/html"), TXT("text/plain"), PDF("application/pdf"); // // private final String mMimeType; // // MimeType(String mimeType) { // mMimeType = mimeType; // } // // public String getMimeType() { // return mMimeType; // } // } // Path: android-client/app/src/main/java/filepickerlibrary/FilePickerBuilder.java import android.app.Activity; import android.content.Context; import android.content.Intent; import android.support.annotation.ColorRes; import filepickerlibrary.enums.MimeType; import filepickerlibrary.enums.Request; import filepickerlibrary.enums.Scope; package filepickerlibrary; /** * Created by Paul on 11/23/2015. */ public class FilePickerBuilder { private final Context mContext; private boolean useMaterial; private Scope mScope = Scope.ALL; private Request requestCode = Request.FILE; private int color = android.R.color.holo_blue_bright;
private MimeType mimeType;
cmusatyalab/faceswap
android-client/app/src/main/java/edu/cmu/cs/gabriel/GabrielConfigurationAsyncTask.java
// Path: android-client/app/src/main/java/edu/cmu/cs/gabriel/network/NetworkProtocol.java // public class NetworkProtocol { // // public static final int NETWORK_RET_FAILED = 1; // public static final int NETWORK_RET_RESULT = 2; // public static final int NETWORK_RET_CONFIG = 3; // public static final int NETWORK_RET_TOKEN = 4; // public static final int NETWORK_MEASUREMENT = 4; // // public static final String HEADER_MESSAGE_CONTROL = "control"; // public static final String HEADER_MESSAGE_RESULT = "result"; // public static final String HEADER_MESSAGE_INJECT_TOKEN = "token_inject"; // public static final String HEADER_MESSAGE_FRAME_ID = "id"; // public static final String HEADER_MESSAGE_ENGINE_ID = "engine_id"; // // public static final String CUSTOM_DATA_MESSAGE_TYPE = "type"; // //response packet data type // public static final String CUSTOM_DATA_MESSAGE_TYPE_ADD_PERSON= "add_person"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_TRAIN= "train"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_DETECT = "detect"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_GET_STATE = "get_state"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_LOAD_STATE = "load_state"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_IMG = "image"; // public static final String CUSTOM_DATA_MESSAGE_VALUE= "value"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_PERSON= "people"; // // // // public static final String CUSTOM_DATA_MESSAGE_NUM = "num"; // public static final String CUSTOM_DATA_MESSAGE_ROI_TEMPLATE_X1 = "item_%_roi_x1"; // public static final String CUSTOM_DATA_MESSAGE_ROI_TEMPLATE_Y1 = "item_%_roi_y1"; // public static final String CUSTOM_DATA_MESSAGE_ROI_TEMPLATE_X2 = "item_%_roi_x2"; // public static final String CUSTOM_DATA_MESSAGE_ROI_TEMPLATE_Y2 = "item_%_roi_y2"; // public static final String CUSTOM_DATA_MESSAGE_IMG_TEMPLATE = "item_%_img"; // // public static final String CUSTOM_DATA_MESSAGE_ROI_X1 = "roi_x1"; // public static final String CUSTOM_DATA_MESSAGE_ROI_Y1 = "roi_y1"; // public static final String CUSTOM_DATA_MESSAGE_ROI_X2 = "roi_x2"; // public static final String CUSTOM_DATA_MESSAGE_ROI_Y2 = "roi_y2"; // public static final String CUSTOM_DATA_MESSAGE_NAME = "name"; // public static final String CUSTOM_DATA_MESSAGE_IMG = "data"; // // // }
import android.app.Activity; import android.app.ProgressDialog; import android.os.AsyncTask; import android.util.Log; import android.widget.Toast; import org.json.JSONException; import org.json.JSONObject; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; import edu.cmu.cs.gabriel.network.NetworkProtocol;
DataOutputStream dos=new DataOutputStream(baos); dos.writeInt(header.length); dos.writeInt(data.length); dos.write(header); dos.write(data); networkWriter.write(baos.toByteArray()); networkWriter.flush(); Log.d(LOG_TAG, "header size: " + header.length+ " data size: " +data.length); } private String receiveMsg(DataInputStream reader) throws IOException { int retLength = reader.readInt(); byte[] recvByte = new byte[retLength]; int readSize = 0; while(readSize < retLength){ int ret = reader.read(recvByte, readSize, retLength-readSize); if(ret <= 0){ break; } readSize += ret; } String receivedString = new String(recvByte); return receivedString; } private String parseResponseData(String response) throws JSONException { JSONObject obj; obj = new JSONObject(response); String result = null;
// Path: android-client/app/src/main/java/edu/cmu/cs/gabriel/network/NetworkProtocol.java // public class NetworkProtocol { // // public static final int NETWORK_RET_FAILED = 1; // public static final int NETWORK_RET_RESULT = 2; // public static final int NETWORK_RET_CONFIG = 3; // public static final int NETWORK_RET_TOKEN = 4; // public static final int NETWORK_MEASUREMENT = 4; // // public static final String HEADER_MESSAGE_CONTROL = "control"; // public static final String HEADER_MESSAGE_RESULT = "result"; // public static final String HEADER_MESSAGE_INJECT_TOKEN = "token_inject"; // public static final String HEADER_MESSAGE_FRAME_ID = "id"; // public static final String HEADER_MESSAGE_ENGINE_ID = "engine_id"; // // public static final String CUSTOM_DATA_MESSAGE_TYPE = "type"; // //response packet data type // public static final String CUSTOM_DATA_MESSAGE_TYPE_ADD_PERSON= "add_person"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_TRAIN= "train"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_DETECT = "detect"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_GET_STATE = "get_state"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_LOAD_STATE = "load_state"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_IMG = "image"; // public static final String CUSTOM_DATA_MESSAGE_VALUE= "value"; // public static final String CUSTOM_DATA_MESSAGE_TYPE_PERSON= "people"; // // // // public static final String CUSTOM_DATA_MESSAGE_NUM = "num"; // public static final String CUSTOM_DATA_MESSAGE_ROI_TEMPLATE_X1 = "item_%_roi_x1"; // public static final String CUSTOM_DATA_MESSAGE_ROI_TEMPLATE_Y1 = "item_%_roi_y1"; // public static final String CUSTOM_DATA_MESSAGE_ROI_TEMPLATE_X2 = "item_%_roi_x2"; // public static final String CUSTOM_DATA_MESSAGE_ROI_TEMPLATE_Y2 = "item_%_roi_y2"; // public static final String CUSTOM_DATA_MESSAGE_IMG_TEMPLATE = "item_%_img"; // // public static final String CUSTOM_DATA_MESSAGE_ROI_X1 = "roi_x1"; // public static final String CUSTOM_DATA_MESSAGE_ROI_Y1 = "roi_y1"; // public static final String CUSTOM_DATA_MESSAGE_ROI_X2 = "roi_x2"; // public static final String CUSTOM_DATA_MESSAGE_ROI_Y2 = "roi_y2"; // public static final String CUSTOM_DATA_MESSAGE_NAME = "name"; // public static final String CUSTOM_DATA_MESSAGE_IMG = "data"; // // // } // Path: android-client/app/src/main/java/edu/cmu/cs/gabriel/GabrielConfigurationAsyncTask.java import android.app.Activity; import android.app.ProgressDialog; import android.os.AsyncTask; import android.util.Log; import android.widget.Toast; import org.json.JSONException; import org.json.JSONObject; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; import edu.cmu.cs.gabriel.network.NetworkProtocol; DataOutputStream dos=new DataOutputStream(baos); dos.writeInt(header.length); dos.writeInt(data.length); dos.write(header); dos.write(data); networkWriter.write(baos.toByteArray()); networkWriter.flush(); Log.d(LOG_TAG, "header size: " + header.length+ " data size: " +data.length); } private String receiveMsg(DataInputStream reader) throws IOException { int retLength = reader.readInt(); byte[] recvByte = new byte[retLength]; int readSize = 0; while(readSize < retLength){ int ret = reader.read(recvByte, readSize, retLength-readSize); if(ret <= 0){ break; } readSize += ret; } String receivedString = new String(recvByte); return receivedString; } private String parseResponseData(String response) throws JSONException { JSONObject obj; obj = new JSONObject(response); String result = null;
result = obj.getString(NetworkProtocol.CUSTOM_DATA_MESSAGE_VALUE);
cmusatyalab/faceswap
android-client/app/src/main/java/edu/cmu/cs/faceswap/IPSettingActivity.java
// Path: android-client/app/src/main/java/edu/cmu/cs/utils/NetworkUtils.java // public class NetworkUtils { // protected static final String // IPV4Pattern = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])"; // protected static final String IPV6Pattern = "([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}"; // // public static boolean isOnline(Context m) { // ConnectivityManager connMgr = (ConnectivityManager) // m.getSystemService(Context.CONNECTIVITY_SERVICE); // NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); // return (networkInfo != null && networkInfo.isConnected()); // } // // public static boolean isIpAddress(String ipAddress) { // if (ipAddress.matches(IPV4Pattern) || ipAddress.matches(IPV6Pattern)) { // return true; // } // return false; // } // // public static boolean checkOnline(Activity a){ // if (isOnline(a)) { // return true; // } // notifyError(Const.CONNECTIVITY_NOT_AVAILABLE, false, a); // return false; // } // // // }
import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Spinner; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; import java.util.HashSet; import java.util.Set; import edu.cmu.cs.utils.NetworkUtils; import static edu.cmu.cs.CustomExceptions.CustomExceptions.notifyError;
//TODO: read off sharedpreferences about current cloudlet ip and cloudip mActivity=this; addIpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = ipNameEditText.getText().toString(); String ip = ipEditText.getText().toString(); //assume type 0 is cloudlet // type 1 is cloud int type=placeSpinner.getSelectedItemPosition(); String sharedPreferenceIpDictName= getResources().getStringArray(R.array.shared_preference_ip_dict_names)[type]; // a deep copy is needed //http://stackoverflow.com/questions/21396358/sharedpreferences-putstringset-doesnt-work Set<String> existingNames = new HashSet<String>(mSharedPreferences.getStringSet(sharedPreferenceIpDictName, new HashSet<String>())); if (name.isEmpty()){ notifyError("Invalid Name", false, mActivity); return; } else if (existingNames.contains(name)){ notifyError("Duplicate Name", false, mActivity); return; } else if (mSharedPreferences.getAll().containsKey(name)){ //TODO: here cloud and cloudlet server cannot share // the same name notifyError("Duplicate Name", false, mActivity); return; }
// Path: android-client/app/src/main/java/edu/cmu/cs/utils/NetworkUtils.java // public class NetworkUtils { // protected static final String // IPV4Pattern = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])"; // protected static final String IPV6Pattern = "([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}"; // // public static boolean isOnline(Context m) { // ConnectivityManager connMgr = (ConnectivityManager) // m.getSystemService(Context.CONNECTIVITY_SERVICE); // NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); // return (networkInfo != null && networkInfo.isConnected()); // } // // public static boolean isIpAddress(String ipAddress) { // if (ipAddress.matches(IPV4Pattern) || ipAddress.matches(IPV6Pattern)) { // return true; // } // return false; // } // // public static boolean checkOnline(Activity a){ // if (isOnline(a)) { // return true; // } // notifyError(Const.CONNECTIVITY_NOT_AVAILABLE, false, a); // return false; // } // // // } // Path: android-client/app/src/main/java/edu/cmu/cs/faceswap/IPSettingActivity.java import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Spinner; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; import java.util.HashSet; import java.util.Set; import edu.cmu.cs.utils.NetworkUtils; import static edu.cmu.cs.CustomExceptions.CustomExceptions.notifyError; //TODO: read off sharedpreferences about current cloudlet ip and cloudip mActivity=this; addIpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = ipNameEditText.getText().toString(); String ip = ipEditText.getText().toString(); //assume type 0 is cloudlet // type 1 is cloud int type=placeSpinner.getSelectedItemPosition(); String sharedPreferenceIpDictName= getResources().getStringArray(R.array.shared_preference_ip_dict_names)[type]; // a deep copy is needed //http://stackoverflow.com/questions/21396358/sharedpreferences-putstringset-doesnt-work Set<String> existingNames = new HashSet<String>(mSharedPreferences.getStringSet(sharedPreferenceIpDictName, new HashSet<String>())); if (name.isEmpty()){ notifyError("Invalid Name", false, mActivity); return; } else if (existingNames.contains(name)){ notifyError("Duplicate Name", false, mActivity); return; } else if (mSharedPreferences.getAll().containsKey(name)){ //TODO: here cloud and cloudlet server cannot share // the same name notifyError("Duplicate Name", false, mActivity); return; }
if (!NetworkUtils.isIpAddress(ip)){
jpmml/jpmml-xgboost
pmml-xgboost/src/main/java/org/jpmml/xgboost/Learner.java
// Path: pmml-xgboost/src/main/java/org/jpmml/xgboost/visitors/TreeModelCompactor.java // public class TreeModelCompactor extends AbstractTreeModelTransformer { // // @Override // public void enterNode(Node node){ // Object id = node.getId(); // Object score = node.getScore(); // Object defaultChild = node.getDefaultChild(); // // if(id == null){ // throw new UnsupportedElementException(node); // } // End if // // if(node.hasNodes()){ // List<Node> children = node.getNodes(); // // if(score != null || defaultChild == null || children.size() != 2){ // throw new UnsupportedElementException(node); // } // // Node firstChild = children.get(0); // Node secondChild = children.get(1); // // SimplePredicate firstPredicate = firstChild.requirePredicate(SimplePredicate.class); // SimplePredicate secondPredicate = secondChild.requirePredicate(SimplePredicate.class); // // checkFieldReference((HasFieldReference<?>)firstPredicate, secondPredicate); // checkValue((HasValue<?>)firstPredicate, secondPredicate); // // if(equalsNode(defaultChild, firstChild)){ // children = swapChildren(node); // // firstChild = children.get(0); // secondChild = children.get(1); // } else // // if(equalsNode(defaultChild, secondChild)){ // // Ignored // } else // // { // throw new UnsupportedElementException(node); // } // // node.setDefaultChild(null); // // secondChild.setPredicate(True.INSTANCE); // } else // // { // if(score == null || defaultChild != null){ // throw new UnsupportedElementException(node); // } // } // // node.setId(null); // } // // @Override // public void exitNode(Node node){ // Predicate predicate = node.requirePredicate(); // // if(predicate instanceof True){ // Node parentNode = getParentNode(); // // if(parentNode == null){ // return; // } // // initScore(parentNode, node); // replaceChildWithGrandchildren(parentNode, node); // } // } // // @Override // public void enterTreeModel(TreeModel treeModel){ // super.enterTreeModel(treeModel); // // TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); // if(missingValueStrategy != TreeModel.MissingValueStrategy.DEFAULT_CHILD){ // throw new UnsupportedAttributeException(treeModel, missingValueStrategy); // } // // TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy(); // if(noTrueChildStrategy != TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION){ // throw new UnsupportedAttributeException(treeModel, noTrueChildStrategy); // } // // TreeModel.SplitCharacteristic splitCharacteristic = treeModel.getSplitCharacteristic(); // if(splitCharacteristic != TreeModel.SplitCharacteristic.BINARY_SPLIT){ // throw new UnsupportedAttributeException(treeModel, splitCharacteristic); // } // // treeModel // .setMissingValueStrategy(TreeModel.MissingValueStrategy.NONE) // .setNoTrueChildStrategy(TreeModel.NoTrueChildStrategy.RETURN_LAST_PREDICTION) // .setSplitCharacteristic(TreeModel.SplitCharacteristic.MULTI_SPLIT); // } // // @Override // public void exitTreeModel(TreeModel treeModel){ // super.exitTreeModel(treeModel); // } // }
import java.io.DataInput; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.function.Function; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.dmg.pmml.DataType; import org.dmg.pmml.PMML; import org.dmg.pmml.Visitor; import org.dmg.pmml.mining.MiningModel; import org.jpmml.converter.BinaryFeature; import org.jpmml.converter.ContinuousFeature; import org.jpmml.converter.Feature; import org.jpmml.converter.Label; import org.jpmml.converter.MissingValueFeature; import org.jpmml.converter.Schema; import org.jpmml.converter.ThresholdFeature; import org.jpmml.converter.visitors.NaNAsMissingDecorator; import org.jpmml.converter.visitors.TreeModelPruner; import org.jpmml.xgboost.visitors.TreeModelCompactor;
PMML pmml = encoder.encodePMML(miningModel); if((Boolean.TRUE).equals(nanAsMissing)){ Visitor visitor = new NaNAsMissingDecorator(); visitor.applyTo(pmml); } return pmml; } public MiningModel encodeMiningModel(Map<String, ?> options, Schema schema){ Boolean compact = (Boolean)options.get(HasXGBoostOptions.OPTION_COMPACT); Boolean numeric = (Boolean)options.get(HasXGBoostOptions.OPTION_NUMERIC); Boolean prune = (Boolean)options.get(HasXGBoostOptions.OPTION_PRUNE); Integer ntreeLimit = (Integer)options.get(HasXGBoostOptions.OPTION_NTREE_LIMIT); if(numeric == null){ numeric = Boolean.TRUE; } MiningModel miningModel = this.gbtree.encodeMiningModel(this.obj, this.base_score, ntreeLimit, numeric, schema) .setAlgorithmName("XGBoost (" + this.gbtree.getAlgorithmName() + ")"); if((Boolean.TRUE).equals(compact)){ if((Boolean.FALSE).equals(numeric)){ throw new IllegalArgumentException("Conflicting XGBoost options"); }
// Path: pmml-xgboost/src/main/java/org/jpmml/xgboost/visitors/TreeModelCompactor.java // public class TreeModelCompactor extends AbstractTreeModelTransformer { // // @Override // public void enterNode(Node node){ // Object id = node.getId(); // Object score = node.getScore(); // Object defaultChild = node.getDefaultChild(); // // if(id == null){ // throw new UnsupportedElementException(node); // } // End if // // if(node.hasNodes()){ // List<Node> children = node.getNodes(); // // if(score != null || defaultChild == null || children.size() != 2){ // throw new UnsupportedElementException(node); // } // // Node firstChild = children.get(0); // Node secondChild = children.get(1); // // SimplePredicate firstPredicate = firstChild.requirePredicate(SimplePredicate.class); // SimplePredicate secondPredicate = secondChild.requirePredicate(SimplePredicate.class); // // checkFieldReference((HasFieldReference<?>)firstPredicate, secondPredicate); // checkValue((HasValue<?>)firstPredicate, secondPredicate); // // if(equalsNode(defaultChild, firstChild)){ // children = swapChildren(node); // // firstChild = children.get(0); // secondChild = children.get(1); // } else // // if(equalsNode(defaultChild, secondChild)){ // // Ignored // } else // // { // throw new UnsupportedElementException(node); // } // // node.setDefaultChild(null); // // secondChild.setPredicate(True.INSTANCE); // } else // // { // if(score == null || defaultChild != null){ // throw new UnsupportedElementException(node); // } // } // // node.setId(null); // } // // @Override // public void exitNode(Node node){ // Predicate predicate = node.requirePredicate(); // // if(predicate instanceof True){ // Node parentNode = getParentNode(); // // if(parentNode == null){ // return; // } // // initScore(parentNode, node); // replaceChildWithGrandchildren(parentNode, node); // } // } // // @Override // public void enterTreeModel(TreeModel treeModel){ // super.enterTreeModel(treeModel); // // TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); // if(missingValueStrategy != TreeModel.MissingValueStrategy.DEFAULT_CHILD){ // throw new UnsupportedAttributeException(treeModel, missingValueStrategy); // } // // TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy(); // if(noTrueChildStrategy != TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION){ // throw new UnsupportedAttributeException(treeModel, noTrueChildStrategy); // } // // TreeModel.SplitCharacteristic splitCharacteristic = treeModel.getSplitCharacteristic(); // if(splitCharacteristic != TreeModel.SplitCharacteristic.BINARY_SPLIT){ // throw new UnsupportedAttributeException(treeModel, splitCharacteristic); // } // // treeModel // .setMissingValueStrategy(TreeModel.MissingValueStrategy.NONE) // .setNoTrueChildStrategy(TreeModel.NoTrueChildStrategy.RETURN_LAST_PREDICTION) // .setSplitCharacteristic(TreeModel.SplitCharacteristic.MULTI_SPLIT); // } // // @Override // public void exitTreeModel(TreeModel treeModel){ // super.exitTreeModel(treeModel); // } // } // Path: pmml-xgboost/src/main/java/org/jpmml/xgboost/Learner.java import java.io.DataInput; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.function.Function; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.dmg.pmml.DataType; import org.dmg.pmml.PMML; import org.dmg.pmml.Visitor; import org.dmg.pmml.mining.MiningModel; import org.jpmml.converter.BinaryFeature; import org.jpmml.converter.ContinuousFeature; import org.jpmml.converter.Feature; import org.jpmml.converter.Label; import org.jpmml.converter.MissingValueFeature; import org.jpmml.converter.Schema; import org.jpmml.converter.ThresholdFeature; import org.jpmml.converter.visitors.NaNAsMissingDecorator; import org.jpmml.converter.visitors.TreeModelPruner; import org.jpmml.xgboost.visitors.TreeModelCompactor; PMML pmml = encoder.encodePMML(miningModel); if((Boolean.TRUE).equals(nanAsMissing)){ Visitor visitor = new NaNAsMissingDecorator(); visitor.applyTo(pmml); } return pmml; } public MiningModel encodeMiningModel(Map<String, ?> options, Schema schema){ Boolean compact = (Boolean)options.get(HasXGBoostOptions.OPTION_COMPACT); Boolean numeric = (Boolean)options.get(HasXGBoostOptions.OPTION_NUMERIC); Boolean prune = (Boolean)options.get(HasXGBoostOptions.OPTION_PRUNE); Integer ntreeLimit = (Integer)options.get(HasXGBoostOptions.OPTION_NTREE_LIMIT); if(numeric == null){ numeric = Boolean.TRUE; } MiningModel miningModel = this.gbtree.encodeMiningModel(this.obj, this.base_score, ntreeLimit, numeric, schema) .setAlgorithmName("XGBoost (" + this.gbtree.getAlgorithmName() + ")"); if((Boolean.TRUE).equals(compact)){ if((Boolean.FALSE).equals(numeric)){ throw new IllegalArgumentException("Conflicting XGBoost options"); }
Visitor visitor = new TreeModelCompactor();
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate collection statistics * * @author Scott Marlow */ public class HibernateCollectionStatistics extends HibernateAbstractStatistics { private static final String ATTRIBUTE_COLLECTION_NAME = "collection-name"; public static final String OPERATION_COLLECTION_LOAD_COUNT = "collection-load-count"; public static final String OPERATION_COLLECTION_FETCH_COUNT = "collection-fetch-count"; public static final String OPERATION_COLLECTION_UPDATE_COUNT = "collection-update-count"; public static final String OPERATION_COLLECTION_REMOVE_COUNT = "collection-remove-count"; public static final String OPERATION_COLLECTION_RECREATED_COUNT = "collection-recreated-count"; public HibernateCollectionStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_COLLECTION_NAME, showCollectionName); types.put(ATTRIBUTE_COLLECTION_NAME,String.class); operations.put(OPERATION_COLLECTION_LOAD_COUNT, collectionLoadCount); types.put(OPERATION_COLLECTION_LOAD_COUNT, Long.class); operations.put(OPERATION_COLLECTION_FETCH_COUNT, collectionFetchCount); types.put(OPERATION_COLLECTION_FETCH_COUNT, Long.class); operations.put(OPERATION_COLLECTION_UPDATE_COUNT, collectionUpdateCount); types.put(OPERATION_COLLECTION_UPDATE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_REMOVE_COUNT, collectionRemoveCount); types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate collection statistics * * @author Scott Marlow */ public class HibernateCollectionStatistics extends HibernateAbstractStatistics { private static final String ATTRIBUTE_COLLECTION_NAME = "collection-name"; public static final String OPERATION_COLLECTION_LOAD_COUNT = "collection-load-count"; public static final String OPERATION_COLLECTION_FETCH_COUNT = "collection-fetch-count"; public static final String OPERATION_COLLECTION_UPDATE_COUNT = "collection-update-count"; public static final String OPERATION_COLLECTION_REMOVE_COUNT = "collection-remove-count"; public static final String OPERATION_COLLECTION_RECREATED_COUNT = "collection-recreated-count"; public HibernateCollectionStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_COLLECTION_NAME, showCollectionName); types.put(ATTRIBUTE_COLLECTION_NAME,String.class); operations.put(OPERATION_COLLECTION_LOAD_COUNT, collectionLoadCount); types.put(OPERATION_COLLECTION_LOAD_COUNT, Long.class); operations.put(OPERATION_COLLECTION_FETCH_COUNT, collectionFetchCount); types.put(OPERATION_COLLECTION_FETCH_COUNT, Long.class); operations.put(OPERATION_COLLECTION_UPDATE_COUNT, collectionUpdateCount); types.put(OPERATION_COLLECTION_UPDATE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_REMOVE_COUNT, collectionRemoveCount); types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate collection statistics * * @author Scott Marlow */ public class HibernateCollectionStatistics extends HibernateAbstractStatistics { private static final String ATTRIBUTE_COLLECTION_NAME = "collection-name"; public static final String OPERATION_COLLECTION_LOAD_COUNT = "collection-load-count"; public static final String OPERATION_COLLECTION_FETCH_COUNT = "collection-fetch-count"; public static final String OPERATION_COLLECTION_UPDATE_COUNT = "collection-update-count"; public static final String OPERATION_COLLECTION_REMOVE_COUNT = "collection-remove-count"; public static final String OPERATION_COLLECTION_RECREATED_COUNT = "collection-recreated-count"; public HibernateCollectionStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_COLLECTION_NAME, showCollectionName); types.put(ATTRIBUTE_COLLECTION_NAME,String.class); operations.put(OPERATION_COLLECTION_LOAD_COUNT, collectionLoadCount); types.put(OPERATION_COLLECTION_LOAD_COUNT, Long.class); operations.put(OPERATION_COLLECTION_FETCH_COUNT, collectionFetchCount); types.put(OPERATION_COLLECTION_FETCH_COUNT, Long.class); operations.put(OPERATION_COLLECTION_UPDATE_COUNT, collectionUpdateCount); types.put(OPERATION_COLLECTION_UPDATE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_REMOVE_COUNT, collectionRemoveCount); types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate collection statistics * * @author Scott Marlow */ public class HibernateCollectionStatistics extends HibernateAbstractStatistics { private static final String ATTRIBUTE_COLLECTION_NAME = "collection-name"; public static final String OPERATION_COLLECTION_LOAD_COUNT = "collection-load-count"; public static final String OPERATION_COLLECTION_FETCH_COUNT = "collection-fetch-count"; public static final String OPERATION_COLLECTION_UPDATE_COUNT = "collection-update-count"; public static final String OPERATION_COLLECTION_REMOVE_COUNT = "collection-remove-count"; public static final String OPERATION_COLLECTION_RECREATED_COUNT = "collection-recreated-count"; public HibernateCollectionStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_COLLECTION_NAME, showCollectionName); types.put(ATTRIBUTE_COLLECTION_NAME,String.class); operations.put(OPERATION_COLLECTION_LOAD_COUNT, collectionLoadCount); types.put(OPERATION_COLLECTION_LOAD_COUNT, Long.class); operations.put(OPERATION_COLLECTION_FETCH_COUNT, collectionFetchCount); types.put(OPERATION_COLLECTION_FETCH_COUNT, Long.class); operations.put(OPERATION_COLLECTION_UPDATE_COUNT, collectionUpdateCount); types.put(OPERATION_COLLECTION_UPDATE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_REMOVE_COUNT, collectionRemoveCount); types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) { return Collections.unmodifiableCollection(Arrays.asList( getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getCollectionRoleNames())); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private CollectionStatistics getStatistics(final EntityManagerFactory entityManagerFactory, String collectionName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics().getCollectionStatistics(collectionName); } return null; }
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) { return Collections.unmodifiableCollection(Arrays.asList( getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getCollectionRoleNames())); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private CollectionStatistics getStatistics(final EntityManagerFactory entityManagerFactory, String collectionName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics().getCollectionStatistics(collectionName); } return null; }
private Operation showCollectionName = new Operation() {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate entity cache (SecondLevelCacheStatistics) statistics * * @author Scott Marlow */ public class HibernateEntityCacheStatistics extends HibernateAbstractStatistics { public static final String ATTRIBUTE_ENTITY_CACHE_REGION_NAME = "entity-cache-region-name"; public static final String OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT = "second-level-cache-hit-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT = "second-level-cache-miss-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT = "second-level-cache-put-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY = "second-level-cache-count-in-memory"; public static final String OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY = "second-level-cache-size-in-memory"; public HibernateEntityCacheStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME, getEntityCacheRegionName); types.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME,String.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, entityCacheHitCount); types.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, entityCacheMissCount); types.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, entityCachePutCount); types.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, entityCacheCountInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, entityCacheSizeInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate entity cache (SecondLevelCacheStatistics) statistics * * @author Scott Marlow */ public class HibernateEntityCacheStatistics extends HibernateAbstractStatistics { public static final String ATTRIBUTE_ENTITY_CACHE_REGION_NAME = "entity-cache-region-name"; public static final String OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT = "second-level-cache-hit-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT = "second-level-cache-miss-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT = "second-level-cache-put-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY = "second-level-cache-count-in-memory"; public static final String OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY = "second-level-cache-size-in-memory"; public HibernateEntityCacheStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME, getEntityCacheRegionName); types.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME,String.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, entityCacheHitCount); types.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, entityCacheMissCount); types.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, entityCachePutCount); types.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, entityCacheCountInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, entityCacheSizeInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate entity cache (SecondLevelCacheStatistics) statistics * * @author Scott Marlow */ public class HibernateEntityCacheStatistics extends HibernateAbstractStatistics { public static final String ATTRIBUTE_ENTITY_CACHE_REGION_NAME = "entity-cache-region-name"; public static final String OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT = "second-level-cache-hit-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT = "second-level-cache-miss-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT = "second-level-cache-put-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY = "second-level-cache-count-in-memory"; public static final String OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY = "second-level-cache-size-in-memory"; public HibernateEntityCacheStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME, getEntityCacheRegionName); types.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME,String.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, entityCacheHitCount); types.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, entityCacheMissCount); types.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, entityCachePutCount); types.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, entityCacheCountInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, entityCacheSizeInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate entity cache (SecondLevelCacheStatistics) statistics * * @author Scott Marlow */ public class HibernateEntityCacheStatistics extends HibernateAbstractStatistics { public static final String ATTRIBUTE_ENTITY_CACHE_REGION_NAME = "entity-cache-region-name"; public static final String OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT = "second-level-cache-hit-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT = "second-level-cache-miss-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT = "second-level-cache-put-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY = "second-level-cache-count-in-memory"; public static final String OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY = "second-level-cache-size-in-memory"; public HibernateEntityCacheStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME, getEntityCacheRegionName); types.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME,String.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, entityCacheHitCount); types.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, entityCacheMissCount); types.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, entityCachePutCount); types.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, entityCacheCountInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, entityCacheSizeInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
} @Override public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) { return Collections.unmodifiableCollection(Arrays.asList( getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getEntityNames())); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName); SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; }
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; } @Override public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) { return Collections.unmodifiableCollection(Arrays.asList( getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getEntityNames())); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName); SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; }
private Operation getEntityCacheRegionName = new Operation() {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate entity cache (SecondLevelCacheStatistics) statistics * * @author Scott Marlow */ public class HibernateEntityCacheStatistics extends HibernateAbstractStatistics { public static final String ATTRIBUTE_ENTITY_CACHE_REGION_NAME = "entity-cache-region-name"; public static final String OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT = "second-level-cache-hit-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT = "second-level-cache-miss-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT = "second-level-cache-put-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY = "second-level-cache-count-in-memory"; public static final String OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY = "second-level-cache-size-in-memory"; public HibernateEntityCacheStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME, getEntityCacheRegionName); types.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME,String.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, entityCacheHitCount); types.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, entityCacheMissCount); types.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, entityCachePutCount); types.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, entityCacheCountInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, entityCacheSizeInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate entity cache (SecondLevelCacheStatistics) statistics * * @author Scott Marlow */ public class HibernateEntityCacheStatistics extends HibernateAbstractStatistics { public static final String ATTRIBUTE_ENTITY_CACHE_REGION_NAME = "entity-cache-region-name"; public static final String OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT = "second-level-cache-hit-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT = "second-level-cache-miss-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT = "second-level-cache-put-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY = "second-level-cache-count-in-memory"; public static final String OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY = "second-level-cache-size-in-memory"; public HibernateEntityCacheStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME, getEntityCacheRegionName); types.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME,String.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, entityCacheHitCount); types.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, entityCacheMissCount); types.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, entityCachePutCount); types.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, entityCacheCountInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, entityCacheSizeInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate entity cache (SecondLevelCacheStatistics) statistics * * @author Scott Marlow */ public class HibernateEntityCacheStatistics extends HibernateAbstractStatistics { public static final String ATTRIBUTE_ENTITY_CACHE_REGION_NAME = "entity-cache-region-name"; public static final String OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT = "second-level-cache-hit-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT = "second-level-cache-miss-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT = "second-level-cache-put-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY = "second-level-cache-count-in-memory"; public static final String OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY = "second-level-cache-size-in-memory"; public HibernateEntityCacheStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME, getEntityCacheRegionName); types.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME,String.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, entityCacheHitCount); types.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, entityCacheMissCount); types.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, entityCachePutCount); types.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, entityCacheCountInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, entityCacheSizeInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate entity cache (SecondLevelCacheStatistics) statistics * * @author Scott Marlow */ public class HibernateEntityCacheStatistics extends HibernateAbstractStatistics { public static final String ATTRIBUTE_ENTITY_CACHE_REGION_NAME = "entity-cache-region-name"; public static final String OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT = "second-level-cache-hit-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT = "second-level-cache-miss-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT = "second-level-cache-put-count"; public static final String OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY = "second-level-cache-count-in-memory"; public static final String OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY = "second-level-cache-size-in-memory"; public HibernateEntityCacheStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME, getEntityCacheRegionName); types.put(ATTRIBUTE_ENTITY_CACHE_REGION_NAME,String.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, entityCacheHitCount); types.put(OPERATION_SECOND_LEVEL_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, entityCacheMissCount); types.put(OPERATION_SECOND_LEVEL_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, entityCachePutCount); types.put(OPERATION_SECOND_LEVEL_CACHE_PUT_COUNT, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, entityCacheCountInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_COUNT_IN_MEMORY, Long.class); operations.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, entityCacheSizeInMemory); types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) { return Collections.unmodifiableCollection(Arrays.asList( getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getEntityNames())); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName); SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; }
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityCacheStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; types.put(OPERATION_SECOND_LEVEL_CACHE_SIZE_IN_MEMORY, Long.class); } @Override public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) { return Collections.unmodifiableCollection(Arrays.asList( getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getEntityNames())); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName); SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; }
private Operation getEntityCacheRegionName = new Operation() {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateManagementAdaptor.java
// Path: spi/src/main/java/org/jboss/as/jpa/spi/ManagementAdaptor.java // @Deprecated // public interface ManagementAdaptor extends org.jipijapa.plugin.spi.ManagementAdaptor { // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jboss.as.jpa.spi.ManagementAdaptor; import org.jipijapa.management.spi.Statistics;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Contains management support for Hibernate * * @author Scott Marlow */ public class HibernateManagementAdaptor implements ManagementAdaptor { // shared (per classloader) instance for all Hibernate 4.1 JPA deployments private static final HibernateManagementAdaptor INSTANCE = new HibernateManagementAdaptor();
// Path: spi/src/main/java/org/jboss/as/jpa/spi/ManagementAdaptor.java // @Deprecated // public interface ManagementAdaptor extends org.jipijapa.plugin.spi.ManagementAdaptor { // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateManagementAdaptor.java import org.jboss.as.jpa.spi.ManagementAdaptor; import org.jipijapa.management.spi.Statistics; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Contains management support for Hibernate * * @author Scott Marlow */ public class HibernateManagementAdaptor implements ManagementAdaptor { // shared (per classloader) instance for all Hibernate 4.1 JPA deployments private static final HibernateManagementAdaptor INSTANCE = new HibernateManagementAdaptor();
private final Statistics statistics = new HibernateStatistics();
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate collection statistics * * @author Scott Marlow */ public class HibernateCollectionStatistics extends HibernateAbstractStatistics { private static final String ATTRIBUTE_COLLECTION_NAME = "collection-name"; public static final String OPERATION_COLLECTION_LOAD_COUNT = "collection-load-count"; public static final String OPERATION_COLLECTION_FETCH_COUNT = "collection-fetch-count"; public static final String OPERATION_COLLECTION_UPDATE_COUNT = "collection-update-count"; public static final String OPERATION_COLLECTION_REMOVE_COUNT = "collection-remove-count"; public static final String OPERATION_COLLECTION_RECREATED_COUNT = "collection-recreated-count"; public HibernateCollectionStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_COLLECTION_NAME, showCollectionName); types.put(ATTRIBUTE_COLLECTION_NAME,String.class); operations.put(OPERATION_COLLECTION_LOAD_COUNT, collectionLoadCount); types.put(OPERATION_COLLECTION_LOAD_COUNT, Long.class); operations.put(OPERATION_COLLECTION_FETCH_COUNT, collectionFetchCount); types.put(OPERATION_COLLECTION_FETCH_COUNT, Long.class); operations.put(OPERATION_COLLECTION_UPDATE_COUNT, collectionUpdateCount); types.put(OPERATION_COLLECTION_UPDATE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_REMOVE_COUNT, collectionRemoveCount); types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate collection statistics * * @author Scott Marlow */ public class HibernateCollectionStatistics extends HibernateAbstractStatistics { private static final String ATTRIBUTE_COLLECTION_NAME = "collection-name"; public static final String OPERATION_COLLECTION_LOAD_COUNT = "collection-load-count"; public static final String OPERATION_COLLECTION_FETCH_COUNT = "collection-fetch-count"; public static final String OPERATION_COLLECTION_UPDATE_COUNT = "collection-update-count"; public static final String OPERATION_COLLECTION_REMOVE_COUNT = "collection-remove-count"; public static final String OPERATION_COLLECTION_RECREATED_COUNT = "collection-recreated-count"; public HibernateCollectionStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_COLLECTION_NAME, showCollectionName); types.put(ATTRIBUTE_COLLECTION_NAME,String.class); operations.put(OPERATION_COLLECTION_LOAD_COUNT, collectionLoadCount); types.put(OPERATION_COLLECTION_LOAD_COUNT, Long.class); operations.put(OPERATION_COLLECTION_FETCH_COUNT, collectionFetchCount); types.put(OPERATION_COLLECTION_FETCH_COUNT, Long.class); operations.put(OPERATION_COLLECTION_UPDATE_COUNT, collectionUpdateCount); types.put(OPERATION_COLLECTION_UPDATE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_REMOVE_COUNT, collectionRemoveCount); types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate collection statistics * * @author Scott Marlow */ public class HibernateCollectionStatistics extends HibernateAbstractStatistics { private static final String ATTRIBUTE_COLLECTION_NAME = "collection-name"; public static final String OPERATION_COLLECTION_LOAD_COUNT = "collection-load-count"; public static final String OPERATION_COLLECTION_FETCH_COUNT = "collection-fetch-count"; public static final String OPERATION_COLLECTION_UPDATE_COUNT = "collection-update-count"; public static final String OPERATION_COLLECTION_REMOVE_COUNT = "collection-remove-count"; public static final String OPERATION_COLLECTION_RECREATED_COUNT = "collection-recreated-count"; public HibernateCollectionStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_COLLECTION_NAME, showCollectionName); types.put(ATTRIBUTE_COLLECTION_NAME,String.class); operations.put(OPERATION_COLLECTION_LOAD_COUNT, collectionLoadCount); types.put(OPERATION_COLLECTION_LOAD_COUNT, Long.class); operations.put(OPERATION_COLLECTION_FETCH_COUNT, collectionFetchCount); types.put(OPERATION_COLLECTION_FETCH_COUNT, Long.class); operations.put(OPERATION_COLLECTION_UPDATE_COUNT, collectionUpdateCount); types.put(OPERATION_COLLECTION_UPDATE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_REMOVE_COUNT, collectionRemoveCount); types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * Hibernate collection statistics * * @author Scott Marlow */ public class HibernateCollectionStatistics extends HibernateAbstractStatistics { private static final String ATTRIBUTE_COLLECTION_NAME = "collection-name"; public static final String OPERATION_COLLECTION_LOAD_COUNT = "collection-load-count"; public static final String OPERATION_COLLECTION_FETCH_COUNT = "collection-fetch-count"; public static final String OPERATION_COLLECTION_UPDATE_COUNT = "collection-update-count"; public static final String OPERATION_COLLECTION_REMOVE_COUNT = "collection-remove-count"; public static final String OPERATION_COLLECTION_RECREATED_COUNT = "collection-recreated-count"; public HibernateCollectionStatistics() { /** * specify the different operations */ operations.put(ATTRIBUTE_COLLECTION_NAME, showCollectionName); types.put(ATTRIBUTE_COLLECTION_NAME,String.class); operations.put(OPERATION_COLLECTION_LOAD_COUNT, collectionLoadCount); types.put(OPERATION_COLLECTION_LOAD_COUNT, Long.class); operations.put(OPERATION_COLLECTION_FETCH_COUNT, collectionFetchCount); types.put(OPERATION_COLLECTION_FETCH_COUNT, Long.class); operations.put(OPERATION_COLLECTION_UPDATE_COUNT, collectionUpdateCount); types.put(OPERATION_COLLECTION_UPDATE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_REMOVE_COUNT, collectionRemoveCount); types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) { return Collections.unmodifiableCollection(Arrays.asList( getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getCollectionRoleNames())); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private CollectionStatistics getStatistics(final EntityManagerFactory entityManagerFactory, String collectionName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics().getCollectionStatistics(collectionName); } return null; }
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateCollectionStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.stat.CollectionStatistics; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; types.put(OPERATION_COLLECTION_REMOVE_COUNT, Long.class); operations.put(OPERATION_COLLECTION_RECREATED_COUNT, collectionRecreatedCount); types.put(OPERATION_COLLECTION_RECREATED_COUNT, Long.class); } @Override public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) { return Collections.unmodifiableCollection(Arrays.asList( getBaseStatistics(entityManagerFactoryLookup.entityManagerFactory(pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL))).getCollectionRoleNames())); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private CollectionStatistics getStatistics(final EntityManagerFactory entityManagerFactory, String collectionName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics().getCollectionStatistics(collectionName); } return null; }
private Operation showCollectionName = new Operation() {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateQueryCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Collection; import java.util.HashSet; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
*/ operations.put(ATTRIBUTE_QUERY_NAME, showQueryName); types.put(ATTRIBUTE_QUERY_NAME,String.class); operations.put(OPERATION_QUERY_EXECUTION_COUNT, queryExecutionCount); types.put(OPERATION_QUERY_EXECUTION_COUNT, Long.class); operations.put(OPERATION_QUERY_EXECUTION_ROW_COUNT, queryExecutionRowCount); types.put(OPERATION_QUERY_EXECUTION_ROW_COUNT, Long.class); operations.put(OPERATION_QUERY_EXECUTION_AVG_TIME, queryExecutionAverageTime); types.put(OPERATION_QUERY_EXECUTION_AVG_TIME, Long.class); operations.put(OPERATION_QUERY_EXECUTION_MAX_TIME, queryExecutionMaximumTime); types.put(OPERATION_QUERY_EXECUTION_MAX_TIME, Long.class); operations.put(OPERATION_QUERY_EXECUTION_MIN_TIME, queryExecutionMinimumTime); types.put(OPERATION_QUERY_EXECUTION_MIN_TIME, Long.class); operations.put(OPERATION_QUERY_CACHE_HIT_COUNT, queryCacheHitCount); types.put(OPERATION_QUERY_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_QUERY_CACHE_MISS_COUNT, queryCacheMissCount); types.put(OPERATION_QUERY_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_QUERY_CACHE_PUT_COUNT, queryCachePutCount); types.put(OPERATION_QUERY_CACHE_PUT_COUNT, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateQueryCacheStatistics.java import java.util.Collection; import java.util.HashSet; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; */ operations.put(ATTRIBUTE_QUERY_NAME, showQueryName); types.put(ATTRIBUTE_QUERY_NAME,String.class); operations.put(OPERATION_QUERY_EXECUTION_COUNT, queryExecutionCount); types.put(OPERATION_QUERY_EXECUTION_COUNT, Long.class); operations.put(OPERATION_QUERY_EXECUTION_ROW_COUNT, queryExecutionRowCount); types.put(OPERATION_QUERY_EXECUTION_ROW_COUNT, Long.class); operations.put(OPERATION_QUERY_EXECUTION_AVG_TIME, queryExecutionAverageTime); types.put(OPERATION_QUERY_EXECUTION_AVG_TIME, Long.class); operations.put(OPERATION_QUERY_EXECUTION_MAX_TIME, queryExecutionMaximumTime); types.put(OPERATION_QUERY_EXECUTION_MAX_TIME, Long.class); operations.put(OPERATION_QUERY_EXECUTION_MIN_TIME, queryExecutionMinimumTime); types.put(OPERATION_QUERY_EXECUTION_MIN_TIME, Long.class); operations.put(OPERATION_QUERY_CACHE_HIT_COUNT, queryCacheHitCount); types.put(OPERATION_QUERY_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_QUERY_CACHE_MISS_COUNT, queryCacheMissCount); types.put(OPERATION_QUERY_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_QUERY_CACHE_PUT_COUNT, queryCachePutCount); types.put(OPERATION_QUERY_CACHE_PUT_COUNT, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateQueryCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Collection; import java.util.HashSet; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
*/ operations.put(ATTRIBUTE_QUERY_NAME, showQueryName); types.put(ATTRIBUTE_QUERY_NAME,String.class); operations.put(OPERATION_QUERY_EXECUTION_COUNT, queryExecutionCount); types.put(OPERATION_QUERY_EXECUTION_COUNT, Long.class); operations.put(OPERATION_QUERY_EXECUTION_ROW_COUNT, queryExecutionRowCount); types.put(OPERATION_QUERY_EXECUTION_ROW_COUNT, Long.class); operations.put(OPERATION_QUERY_EXECUTION_AVG_TIME, queryExecutionAverageTime); types.put(OPERATION_QUERY_EXECUTION_AVG_TIME, Long.class); operations.put(OPERATION_QUERY_EXECUTION_MAX_TIME, queryExecutionMaximumTime); types.put(OPERATION_QUERY_EXECUTION_MAX_TIME, Long.class); operations.put(OPERATION_QUERY_EXECUTION_MIN_TIME, queryExecutionMinimumTime); types.put(OPERATION_QUERY_EXECUTION_MIN_TIME, Long.class); operations.put(OPERATION_QUERY_CACHE_HIT_COUNT, queryCacheHitCount); types.put(OPERATION_QUERY_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_QUERY_CACHE_MISS_COUNT, queryCacheMissCount); types.put(OPERATION_QUERY_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_QUERY_CACHE_PUT_COUNT, queryCachePutCount); types.put(OPERATION_QUERY_CACHE_PUT_COUNT, Long.class); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateQueryCacheStatistics.java import java.util.Collection; import java.util.HashSet; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; */ operations.put(ATTRIBUTE_QUERY_NAME, showQueryName); types.put(ATTRIBUTE_QUERY_NAME,String.class); operations.put(OPERATION_QUERY_EXECUTION_COUNT, queryExecutionCount); types.put(OPERATION_QUERY_EXECUTION_COUNT, Long.class); operations.put(OPERATION_QUERY_EXECUTION_ROW_COUNT, queryExecutionRowCount); types.put(OPERATION_QUERY_EXECUTION_ROW_COUNT, Long.class); operations.put(OPERATION_QUERY_EXECUTION_AVG_TIME, queryExecutionAverageTime); types.put(OPERATION_QUERY_EXECUTION_AVG_TIME, Long.class); operations.put(OPERATION_QUERY_EXECUTION_MAX_TIME, queryExecutionMaximumTime); types.put(OPERATION_QUERY_EXECUTION_MAX_TIME, Long.class); operations.put(OPERATION_QUERY_EXECUTION_MIN_TIME, queryExecutionMinimumTime); types.put(OPERATION_QUERY_EXECUTION_MIN_TIME, Long.class); operations.put(OPERATION_QUERY_CACHE_HIT_COUNT, queryCacheHitCount); types.put(OPERATION_QUERY_CACHE_HIT_COUNT, Long.class); operations.put(OPERATION_QUERY_CACHE_MISS_COUNT, queryCacheMissCount); types.put(OPERATION_QUERY_CACHE_MISS_COUNT, Long.class); operations.put(OPERATION_QUERY_CACHE_PUT_COUNT, queryCachePutCount); types.put(OPERATION_QUERY_CACHE_PUT_COUNT, Long.class); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateQueryCacheStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Collection; import java.util.HashSet; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
} return result; } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private org.hibernate.stat.QueryStatistics getStatistics(EntityManagerFactory entityManagerFactory, String displayQueryName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); // convert displayed (transformed by QueryNames) query name to original query name to look up query statistics if (sessionFactory != null) { String[] originalQueryNames = sessionFactory.getStatistics().getQueries(); if (originalQueryNames != null) { for (String originalQueryName : originalQueryNames) { if (QueryName.queryName(originalQueryName).getDisplayName().equals(displayQueryName)) { return sessionFactory.getStatistics().getQueryStatistics(originalQueryName); } } } } return null; }
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateQueryCacheStatistics.java import java.util.Collection; import java.util.HashSet; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; } return result; } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private org.hibernate.stat.QueryStatistics getStatistics(EntityManagerFactory entityManagerFactory, String displayQueryName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); // convert displayed (transformed by QueryNames) query name to original query name to look up query statistics if (sessionFactory != null) { String[] originalQueryNames = sessionFactory.getStatistics().getQueries(); if (originalQueryNames != null) { for (String originalQueryName : originalQueryNames) { if (QueryName.queryName(originalQueryName).getDisplayName().equals(displayQueryName)) { return sessionFactory.getStatistics().getQueryStatistics(originalQueryName); } } } } return null; }
private Operation queryExecutionCount = new Operation() {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
types.put(OPERATION_ENTITY_LOAD_COUNT, Long.class); operations.put(OPERATION_ENTITY_FETCH_COUNT, entityFetchCount); types.put(OPERATION_ENTITY_FETCH_COUNT, Long.class); operations.put(OPERATION_ENTITY_UPDATE_COUNT, entityUpdateCount); types.put(OPERATION_ENTITY_UPDATE_COUNT, Long.class); operations.put(OPERATION_OPTIMISTIC_FAILURE_COUNT, optimisticFailureCount); types.put(OPERATION_OPTIMISTIC_FAILURE_COUNT, Long.class); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private org.hibernate.stat.EntityStatistics getStatistics(EntityManagerFactory entityManagerFactory, String entityName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics().getEntityStatistics(entityName); } return null; }
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; types.put(OPERATION_ENTITY_LOAD_COUNT, Long.class); operations.put(OPERATION_ENTITY_FETCH_COUNT, entityFetchCount); types.put(OPERATION_ENTITY_FETCH_COUNT, Long.class); operations.put(OPERATION_ENTITY_UPDATE_COUNT, entityUpdateCount); types.put(OPERATION_ENTITY_UPDATE_COUNT, Long.class); operations.put(OPERATION_OPTIMISTIC_FAILURE_COUNT, optimisticFailureCount); types.put(OPERATION_OPTIMISTIC_FAILURE_COUNT, Long.class); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private org.hibernate.stat.EntityStatistics getStatistics(EntityManagerFactory entityManagerFactory, String entityName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics().getEntityStatistics(entityName); } return null; }
private Operation entityDeleteCount = new Operation() {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
@Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } }; private Operation entityUpdateCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } }; private Operation optimisticFailureCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getOptimisticFailureCount() : 0); } }; @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } }; private Operation entityUpdateCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } }; private Operation optimisticFailureCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getOptimisticFailureCount() : 0); } }; @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
@Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } }; private Operation entityUpdateCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } }; private Operation optimisticFailureCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getOptimisticFailureCount() : 0); } }; @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } }; private Operation entityUpdateCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } }; private Operation optimisticFailureCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getOptimisticFailureCount() : 0); } }; @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
public static final String OPERATION_QUERYEXECUTION_MAX_TIME ="query-execution-max-time"; public static final String OPERATION_QUERYEXECUTION_MAX_TIME_STRING ="query-execution-max-time-query-string"; public static final String OPERATION_SECONDLEVELCACHE_HIT_COUNT= "second-level-cache-hit-count"; public static final String OPERATION_SECONDLEVELCACHE_MISS_COUNT="second-level-cache-miss-count"; public static final String OPERATION_SECONDLEVELCACHE_PUT_COUNT="second-level-cache-put-count"; public static final String OPERATION_FLUSH_COUNT = "flush-count"; public static final String OPERATION_CONNECT_COUNT = "connect-count"; public static final String OPERATION_SESSION_CLOSE_COUNT = "session-close-count"; public static final String OPERATION_SESSION_OPEN_COUNT = "session-open-count"; public static final String OPERATION_SUCCESSFUL_TRANSACTION_COUNT = "successful-transaction-count"; public static final String OPERATION_COMPLETED_TRANSACTION_COUNT = "completed-transaction-count"; public static final String OPERATION_PREPARED_STATEMENT_COUNT = "prepared-statement-count"; public static final String OPERATION_CLOSE_STATEMENT_COUNT = "close-statement-count"; public static final String OPERATION_OPTIMISTIC_FAILURE_COUNT = "optimistic-failure-count"; public static final String ENTITYCACHE = "entity-cache"; public static final String COLLECTION = "collection"; public static final String ENTITY = "entity"; public static final String QUERYCACHE = "query-cache"; private final Map<String, Statistics> childrenStatistics = new HashMap<String,Statistics>(); public HibernateStatistics() { /** * specify the different operations */ operations.put(PROVIDER_LABEL, label); types.put(PROVIDER_LABEL,String.class); operations.put(OPERATION_CLEAR, clear);
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; public static final String OPERATION_QUERYEXECUTION_MAX_TIME ="query-execution-max-time"; public static final String OPERATION_QUERYEXECUTION_MAX_TIME_STRING ="query-execution-max-time-query-string"; public static final String OPERATION_SECONDLEVELCACHE_HIT_COUNT= "second-level-cache-hit-count"; public static final String OPERATION_SECONDLEVELCACHE_MISS_COUNT="second-level-cache-miss-count"; public static final String OPERATION_SECONDLEVELCACHE_PUT_COUNT="second-level-cache-put-count"; public static final String OPERATION_FLUSH_COUNT = "flush-count"; public static final String OPERATION_CONNECT_COUNT = "connect-count"; public static final String OPERATION_SESSION_CLOSE_COUNT = "session-close-count"; public static final String OPERATION_SESSION_OPEN_COUNT = "session-open-count"; public static final String OPERATION_SUCCESSFUL_TRANSACTION_COUNT = "successful-transaction-count"; public static final String OPERATION_COMPLETED_TRANSACTION_COUNT = "completed-transaction-count"; public static final String OPERATION_PREPARED_STATEMENT_COUNT = "prepared-statement-count"; public static final String OPERATION_CLOSE_STATEMENT_COUNT = "close-statement-count"; public static final String OPERATION_OPTIMISTIC_FAILURE_COUNT = "optimistic-failure-count"; public static final String ENTITYCACHE = "entity-cache"; public static final String COLLECTION = "collection"; public static final String ENTITY = "entity"; public static final String QUERYCACHE = "query-cache"; private final Map<String, Statistics> childrenStatistics = new HashMap<String,Statistics>(); public HibernateStatistics() { /** * specify the different operations */ operations.put(PROVIDER_LABEL, label); types.put(PROVIDER_LABEL,String.class); operations.put(OPERATION_CLEAR, clear);
types.put(OPERATION_CLEAR, Operation.class);
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
*/ childrenNames.add(ENTITY); childrenStatistics.put(ENTITY, new HibernateEntityStatistics()); childrenNames.add(ENTITYCACHE); childrenStatistics.put(ENTITYCACHE, new HibernateEntityCacheStatistics()); childrenNames.add(COLLECTION); childrenStatistics.put(COLLECTION, new HibernateCollectionStatistics()); childrenNames.add(QUERYCACHE); childrenStatistics.put(QUERYCACHE , new HibernateQueryCacheStatistics()); } @Override public Statistics getChild(String childName) { return childrenStatistics.get(childName); } static final org.hibernate.stat.Statistics getStatistics(final EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; */ childrenNames.add(ENTITY); childrenStatistics.put(ENTITY, new HibernateEntityStatistics()); childrenNames.add(ENTITYCACHE); childrenStatistics.put(ENTITYCACHE, new HibernateEntityCacheStatistics()); childrenNames.add(COLLECTION); childrenStatistics.put(COLLECTION, new HibernateCollectionStatistics()); childrenNames.add(QUERYCACHE); childrenStatistics.put(QUERYCACHE , new HibernateQueryCacheStatistics()); } @Override public Statistics getChild(String childName) { return childrenStatistics.get(childName); } static final org.hibernate.stat.Statistics getStatistics(final EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
*/ childrenNames.add(ENTITY); childrenStatistics.put(ENTITY, new HibernateEntityStatistics()); childrenNames.add(ENTITYCACHE); childrenStatistics.put(ENTITYCACHE, new HibernateEntityCacheStatistics()); childrenNames.add(COLLECTION); childrenStatistics.put(COLLECTION, new HibernateCollectionStatistics()); childrenNames.add(QUERYCACHE); childrenStatistics.put(QUERYCACHE , new HibernateQueryCacheStatistics()); } @Override public Statistics getChild(String childName) { return childrenStatistics.get(childName); } static final org.hibernate.stat.Statistics getStatistics(final EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; */ childrenNames.add(ENTITY); childrenStatistics.put(ENTITY, new HibernateEntityStatistics()); childrenNames.add(ENTITYCACHE); childrenStatistics.put(ENTITYCACHE, new HibernateEntityCacheStatistics()); childrenNames.add(COLLECTION); childrenStatistics.put(COLLECTION, new HibernateCollectionStatistics()); childrenNames.add(QUERYCACHE); childrenStatistics.put(QUERYCACHE , new HibernateQueryCacheStatistics()); } @Override public Statistics getChild(String childName) { return childrenStatistics.get(childName); } static final org.hibernate.stat.Statistics getStatistics(final EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
public static final String OPERATION_QUERYEXECUTION_MAX_TIME ="query-execution-max-time"; public static final String OPERATION_QUERYEXECUTION_MAX_TIME_STRING ="query-execution-max-time-query-string"; public static final String OPERATION_SECONDLEVELCACHE_HIT_COUNT= "second-level-cache-hit-count"; public static final String OPERATION_SECONDLEVELCACHE_MISS_COUNT="second-level-cache-miss-count"; public static final String OPERATION_SECONDLEVELCACHE_PUT_COUNT="second-level-cache-put-count"; public static final String OPERATION_FLUSH_COUNT = "flush-count"; public static final String OPERATION_CONNECT_COUNT = "connect-count"; public static final String OPERATION_SESSION_CLOSE_COUNT = "session-close-count"; public static final String OPERATION_SESSION_OPEN_COUNT = "session-open-count"; public static final String OPERATION_SUCCESSFUL_TRANSACTION_COUNT = "successful-transaction-count"; public static final String OPERATION_COMPLETED_TRANSACTION_COUNT = "completed-transaction-count"; public static final String OPERATION_PREPARED_STATEMENT_COUNT = "prepared-statement-count"; public static final String OPERATION_CLOSE_STATEMENT_COUNT = "close-statement-count"; public static final String OPERATION_OPTIMISTIC_FAILURE_COUNT = "optimistic-failure-count"; public static final String ENTITYCACHE = "entity-cache"; public static final String COLLECTION = "collection"; public static final String ENTITY = "entity"; public static final String QUERYCACHE = "query-cache"; private final Map<String, Statistics> childrenStatistics = new HashMap<String,Statistics>(); public HibernateStatistics() { /** * specify the different operations */ operations.put(PROVIDER_LABEL, label); types.put(PROVIDER_LABEL,String.class); operations.put(OPERATION_CLEAR, clear);
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; public static final String OPERATION_QUERYEXECUTION_MAX_TIME ="query-execution-max-time"; public static final String OPERATION_QUERYEXECUTION_MAX_TIME_STRING ="query-execution-max-time-query-string"; public static final String OPERATION_SECONDLEVELCACHE_HIT_COUNT= "second-level-cache-hit-count"; public static final String OPERATION_SECONDLEVELCACHE_MISS_COUNT="second-level-cache-miss-count"; public static final String OPERATION_SECONDLEVELCACHE_PUT_COUNT="second-level-cache-put-count"; public static final String OPERATION_FLUSH_COUNT = "flush-count"; public static final String OPERATION_CONNECT_COUNT = "connect-count"; public static final String OPERATION_SESSION_CLOSE_COUNT = "session-close-count"; public static final String OPERATION_SESSION_OPEN_COUNT = "session-open-count"; public static final String OPERATION_SUCCESSFUL_TRANSACTION_COUNT = "successful-transaction-count"; public static final String OPERATION_COMPLETED_TRANSACTION_COUNT = "completed-transaction-count"; public static final String OPERATION_PREPARED_STATEMENT_COUNT = "prepared-statement-count"; public static final String OPERATION_CLOSE_STATEMENT_COUNT = "close-statement-count"; public static final String OPERATION_OPTIMISTIC_FAILURE_COUNT = "optimistic-failure-count"; public static final String ENTITYCACHE = "entity-cache"; public static final String COLLECTION = "collection"; public static final String ENTITY = "entity"; public static final String QUERYCACHE = "query-cache"; private final Map<String, Statistics> childrenStatistics = new HashMap<String,Statistics>(); public HibernateStatistics() { /** * specify the different operations */ operations.put(PROVIDER_LABEL, label); types.put(PROVIDER_LABEL,String.class); operations.put(OPERATION_CLEAR, clear);
types.put(OPERATION_CLEAR, Operation.class);
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
childrenNames.add(ENTITY); //childrenStatistics.put(ENTITY, new HibernateEntityStatisticsNames()); // let user choose from different entity names childrenStatistics.put(ENTITY, new HibernateEntityStatistics()); childrenNames.add(ENTITYCACHE); childrenStatistics.put(ENTITYCACHE, new HibernateEntityCacheStatistics()); childrenNames.add(COLLECTION); childrenStatistics.put(COLLECTION, new HibernateCollectionStatistics()); childrenNames.add(QUERYCACHE); childrenStatistics.put(QUERYCACHE , new HibernateQueryCacheStatistics()); } @Override public Statistics getChild(String childName) { return childrenStatistics.get(childName); } static final org.hibernate.stat.Statistics getStatistics(final EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; childrenNames.add(ENTITY); //childrenStatistics.put(ENTITY, new HibernateEntityStatisticsNames()); // let user choose from different entity names childrenStatistics.put(ENTITY, new HibernateEntityStatistics()); childrenNames.add(ENTITYCACHE); childrenStatistics.put(ENTITYCACHE, new HibernateEntityCacheStatistics()); childrenNames.add(COLLECTION); childrenStatistics.put(COLLECTION, new HibernateCollectionStatistics()); childrenNames.add(QUERYCACHE); childrenStatistics.put(QUERYCACHE , new HibernateQueryCacheStatistics()); } @Override public Statistics getChild(String childName) { return childrenStatistics.get(childName); } static final org.hibernate.stat.Statistics getStatistics(final EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
childrenNames.add(ENTITY); //childrenStatistics.put(ENTITY, new HibernateEntityStatisticsNames()); // let user choose from different entity names childrenStatistics.put(ENTITY, new HibernateEntityStatistics()); childrenNames.add(ENTITYCACHE); childrenStatistics.put(ENTITYCACHE, new HibernateEntityCacheStatistics()); childrenNames.add(COLLECTION); childrenStatistics.put(COLLECTION, new HibernateCollectionStatistics()); childrenNames.add(QUERYCACHE); childrenStatistics.put(QUERYCACHE , new HibernateQueryCacheStatistics()); } @Override public Statistics getChild(String childName) { return childrenStatistics.get(childName); } static final org.hibernate.stat.Statistics getStatistics(final EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateStatistics.java import org.jipijapa.management.spi.Statistics; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.persistence.Cache; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; childrenNames.add(ENTITY); //childrenStatistics.put(ENTITY, new HibernateEntityStatisticsNames()); // let user choose from different entity names childrenStatistics.put(ENTITY, new HibernateEntityStatistics()); childrenNames.add(ENTITYCACHE); childrenStatistics.put(ENTITYCACHE, new HibernateEntityCacheStatistics()); childrenNames.add(COLLECTION); childrenStatistics.put(COLLECTION, new HibernateCollectionStatistics()); childrenNames.add(QUERYCACHE); childrenStatistics.put(QUERYCACHE , new HibernateQueryCacheStatistics()); } @Override public Statistics getChild(String childName) { return childrenStatistics.get(childName); } static final org.hibernate.stat.Statistics getStatistics(final EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
types.put(OPERATION_ENTITY_LOAD_COUNT, Long.class); operations.put(OPERATION_ENTITY_FETCH_COUNT, entityFetchCount); types.put(OPERATION_ENTITY_FETCH_COUNT, Long.class); operations.put(OPERATION_ENTITY_UPDATE_COUNT, entityUpdateCount); types.put(OPERATION_ENTITY_UPDATE_COUNT, Long.class); operations.put(OPERATION_OPTIMISTIC_FAILURE_COUNT, optimisticFailureCount); types.put(OPERATION_OPTIMISTIC_FAILURE_COUNT, Long.class); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private org.hibernate.stat.EntityStatistics getStatistics(EntityManagerFactory entityManagerFactory, String entityName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics().getEntityStatistics(entityName); } return null; }
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; types.put(OPERATION_ENTITY_LOAD_COUNT, Long.class); operations.put(OPERATION_ENTITY_FETCH_COUNT, entityFetchCount); types.put(OPERATION_ENTITY_FETCH_COUNT, Long.class); operations.put(OPERATION_ENTITY_UPDATE_COUNT, entityUpdateCount); types.put(OPERATION_ENTITY_UPDATE_COUNT, Long.class); operations.put(OPERATION_OPTIMISTIC_FAILURE_COUNT, optimisticFailureCount); types.put(OPERATION_OPTIMISTIC_FAILURE_COUNT, Long.class); } private org.hibernate.stat.Statistics getBaseStatistics(EntityManagerFactory entityManagerFactory) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics(); } return null; } private org.hibernate.stat.EntityStatistics getStatistics(EntityManagerFactory entityManagerFactory, String entityName) { HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactory; SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { return sessionFactory.getStatistics().getEntityStatistics(entityName); } return null; }
private Operation entityDeleteCount = new Operation() {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
@Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } }; private Operation entityUpdateCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } }; private Operation optimisticFailureCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getOptimisticFailureCount() : 0); } }; @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } }; private Operation entityUpdateCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } }; private Operation optimisticFailureCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getOptimisticFailureCount() : 0); } }; @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // }
import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
@Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } }; private Operation entityUpdateCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } }; private Operation optimisticFailureCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getOptimisticFailureCount() : 0); } }; @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // Path: hibernate4_1/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateEntityStatistics.java import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.hibernate.SessionFactory; import org.hibernate.ejb.HibernateEntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getLoadCount() : 0); } }; private Operation entityUpdateCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getUpdateCount() : 0); } }; private Operation optimisticFailureCount = new Operation() { @Override public Object invoke(Object... args) { org.hibernate.stat.EntityStatistics statistics = getStatistics(getEntityManagerFactory(args), getStatisticName(args)); return Long.valueOf(statistics != null ? statistics.getOptimisticFailureCount() : 0); } }; @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override
public Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryLookup, PathAddress pathAddress) {
jipijapa/jipijapa
spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java
// Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.Statistics;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.plugin.spi; /** * Defines persistence provider management operations/statistics * * @author Scott Marlow */ public interface ManagementAdaptor { /** * Get the short identification string that represents the management adaptor (e.g Hibernate) * * @return id label */ String getIdentificationLabel(); /** * Version that uniquely identifies the management adapter (can be used to tell the difference between * Hibernate 4.1 vs 4.3). * * @return version string */ String getVersion();
// Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java import org.jipijapa.management.spi.Statistics; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.plugin.spi; /** * Defines persistence provider management operations/statistics * * @author Scott Marlow */ public interface ManagementAdaptor { /** * Get the short identification string that represents the management adaptor (e.g Hibernate) * * @return id label */ String getIdentificationLabel(); /** * Version that uniquely identifies the management adapter (can be used to tell the difference between * Hibernate 4.1 vs 4.3). * * @return version string */ String getVersion();
Statistics getStatistics();
jipijapa/jipijapa
eclipselink/src/main/java/org/jipijapa/eclipselink/EclipseLinkPersistenceProviderAdaptor.java
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // }
import java.util.Map; import org.jboss.logging.Logger; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform;
} else { // Version-specific handling here if ( (major == 2 && minor == 3 && rev <= 2) || (major == 2 && minor < 3) ) { logger.info("Enabling workaronud for EclipseLink bug 365704 for EclipseLink 2.3.2 and older"); hasJTABug = true; } else { hasJTABug = false; } } } @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) { if (!properties.containsKey(ECLIPSELINK_TARGET_SERVER)) { properties.put(ECLIPSELINK_TARGET_SERVER, JBossAS7ServerPlatform.class.getName()); properties.put(ECLIPSELINK_ARCHIVE_FACTORY, JBossArchiveFactoryImpl.class.getName()); properties.put(ECLIPSELINK_LOGGING_LOGGER, JBossLogger.class.getName()); } logger.trace("Property " + ECLIPSELINK_TARGET_SERVER + " set to " + properties.get(ECLIPSELINK_TARGET_SERVER)); logger.trace("Property " + ECLIPSELINK_ARCHIVE_FACTORY + " set to " + properties.get(ECLIPSELINK_ARCHIVE_FACTORY)); logger.trace("Property " + ECLIPSELINK_LOGGING_LOGGER + " set to " + properties.get(ECLIPSELINK_LOGGING_LOGGER)); } @Override public void injectJtaManager(JtaManager jtaManager) { // No action required, EclipseLink looks this up from JNDI } @Override
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // } // Path: eclipselink/src/main/java/org/jipijapa/eclipselink/EclipseLinkPersistenceProviderAdaptor.java import java.util.Map; import org.jboss.logging.Logger; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform; } else { // Version-specific handling here if ( (major == 2 && minor == 3 && rev <= 2) || (major == 2 && minor < 3) ) { logger.info("Enabling workaronud for EclipseLink bug 365704 for EclipseLink 2.3.2 and older"); hasJTABug = true; } else { hasJTABug = false; } } } @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) { if (!properties.containsKey(ECLIPSELINK_TARGET_SERVER)) { properties.put(ECLIPSELINK_TARGET_SERVER, JBossAS7ServerPlatform.class.getName()); properties.put(ECLIPSELINK_ARCHIVE_FACTORY, JBossArchiveFactoryImpl.class.getName()); properties.put(ECLIPSELINK_LOGGING_LOGGER, JBossLogger.class.getName()); } logger.trace("Property " + ECLIPSELINK_TARGET_SERVER + " set to " + properties.get(ECLIPSELINK_TARGET_SERVER)); logger.trace("Property " + ECLIPSELINK_ARCHIVE_FACTORY + " set to " + properties.get(ECLIPSELINK_ARCHIVE_FACTORY)); logger.trace("Property " + ECLIPSELINK_LOGGING_LOGGER + " set to " + properties.get(ECLIPSELINK_LOGGING_LOGGER)); } @Override public void injectJtaManager(JtaManager jtaManager) { // No action required, EclipseLink looks this up from JNDI } @Override
public void injectPlatform(Platform platform) {
jipijapa/jipijapa
eclipselink/src/main/java/org/jipijapa/eclipselink/EclipseLinkPersistenceProviderAdaptor.java
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // }
import java.util.Map; import org.jboss.logging.Logger; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform;
} @Override public void injectJtaManager(JtaManager jtaManager) { // No action required, EclipseLink looks this up from JNDI } @Override public void injectPlatform(Platform platform) { } @Override public void addProviderDependencies(PersistenceUnitMetadata pu) { // No action required } @Override public void beforeCreateContainerEntityManagerFactory( PersistenceUnitMetadata pu) { // no action required } @Override public void afterCreateContainerEntityManagerFactory( PersistenceUnitMetadata pu) { // TODO: Force creation of metamodel here? } @Override
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // } // Path: eclipselink/src/main/java/org/jipijapa/eclipselink/EclipseLinkPersistenceProviderAdaptor.java import java.util.Map; import org.jboss.logging.Logger; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform; } @Override public void injectJtaManager(JtaManager jtaManager) { // No action required, EclipseLink looks this up from JNDI } @Override public void injectPlatform(Platform platform) { } @Override public void addProviderDependencies(PersistenceUnitMetadata pu) { // No action required } @Override public void beforeCreateContainerEntityManagerFactory( PersistenceUnitMetadata pu) { // no action required } @Override public void afterCreateContainerEntityManagerFactory( PersistenceUnitMetadata pu) { // TODO: Force creation of metamodel here? } @Override
public ManagementAdaptor getManagementAdaptor() {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateAbstractStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/StatisticName.java // public interface StatisticName { // /** // * returns the statistic name // * @return // */ // String getName(); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.StatisticName; import org.jipijapa.management.spi.Statistics; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * HibernateAbstractStatistics * * @author Scott Marlow */ public abstract class HibernateAbstractStatistics implements Statistics { private static final String RESOURCE_BUNDLE = HibernateAbstractStatistics.class.getPackage().getName() + ".LocalDescriptions"; private static final String RESOURCE_BUNDLE_KEY_PREFIX = "hibernate";
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/StatisticName.java // public interface StatisticName { // /** // * returns the statistic name // * @return // */ // String getName(); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateAbstractStatistics.java import org.jipijapa.management.spi.StatisticName; import org.jipijapa.management.spi.Statistics; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * HibernateAbstractStatistics * * @author Scott Marlow */ public abstract class HibernateAbstractStatistics implements Statistics { private static final String RESOURCE_BUNDLE = HibernateAbstractStatistics.class.getPackage().getName() + ".LocalDescriptions"; private static final String RESOURCE_BUNDLE_KEY_PREFIX = "hibernate";
protected Map<String,Operation> operations = new HashMap<String, Operation>();
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateAbstractStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/StatisticName.java // public interface StatisticName { // /** // * returns the statistic name // * @return // */ // String getName(); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.StatisticName; import org.jipijapa.management.spi.Statistics; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * HibernateAbstractStatistics * * @author Scott Marlow */ public abstract class HibernateAbstractStatistics implements Statistics { private static final String RESOURCE_BUNDLE = HibernateAbstractStatistics.class.getPackage().getName() + ".LocalDescriptions"; private static final String RESOURCE_BUNDLE_KEY_PREFIX = "hibernate"; protected Map<String,Operation> operations = new HashMap<String, Operation>(); protected Set<String> childrenNames = new HashSet<String>(); protected Set<String> writeableNames = new HashSet<String>(); protected Map<String, Class> types = new HashMap<String, Class>(); protected Map<Locale, ResourceBundle> rbs = new HashMap<Locale, ResourceBundle>(); @Override public String getResourceBundleName() { return RESOURCE_BUNDLE; } @Override public String getResourceBundleKeyPrefix() { return RESOURCE_BUNDLE_KEY_PREFIX; } protected EntityManagerFactory getEntityManagerFactory(Object[] args) {
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/StatisticName.java // public interface StatisticName { // /** // * returns the statistic name // * @return // */ // String getName(); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateAbstractStatistics.java import org.jipijapa.management.spi.StatisticName; import org.jipijapa.management.spi.Statistics; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * HibernateAbstractStatistics * * @author Scott Marlow */ public abstract class HibernateAbstractStatistics implements Statistics { private static final String RESOURCE_BUNDLE = HibernateAbstractStatistics.class.getPackage().getName() + ".LocalDescriptions"; private static final String RESOURCE_BUNDLE_KEY_PREFIX = "hibernate"; protected Map<String,Operation> operations = new HashMap<String, Operation>(); protected Set<String> childrenNames = new HashSet<String>(); protected Set<String> writeableNames = new HashSet<String>(); protected Map<String, Class> types = new HashMap<String, Class>(); protected Map<Locale, ResourceBundle> rbs = new HashMap<Locale, ResourceBundle>(); @Override public String getResourceBundleName() { return RESOURCE_BUNDLE; } @Override public String getResourceBundleKeyPrefix() { return RESOURCE_BUNDLE_KEY_PREFIX; } protected EntityManagerFactory getEntityManagerFactory(Object[] args) {
PathAddress pathAddress = getPathAddress(args);
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateAbstractStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/StatisticName.java // public interface StatisticName { // /** // * returns the statistic name // * @return // */ // String getName(); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.StatisticName; import org.jipijapa.management.spi.Statistics; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * HibernateAbstractStatistics * * @author Scott Marlow */ public abstract class HibernateAbstractStatistics implements Statistics { private static final String RESOURCE_BUNDLE = HibernateAbstractStatistics.class.getPackage().getName() + ".LocalDescriptions"; private static final String RESOURCE_BUNDLE_KEY_PREFIX = "hibernate"; protected Map<String,Operation> operations = new HashMap<String, Operation>(); protected Set<String> childrenNames = new HashSet<String>(); protected Set<String> writeableNames = new HashSet<String>(); protected Map<String, Class> types = new HashMap<String, Class>(); protected Map<Locale, ResourceBundle> rbs = new HashMap<Locale, ResourceBundle>(); @Override public String getResourceBundleName() { return RESOURCE_BUNDLE; } @Override public String getResourceBundleKeyPrefix() { return RESOURCE_BUNDLE_KEY_PREFIX; } protected EntityManagerFactory getEntityManagerFactory(Object[] args) { PathAddress pathAddress = getPathAddress(args); for(Object arg :args) {
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/StatisticName.java // public interface StatisticName { // /** // * returns the statistic name // * @return // */ // String getName(); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateAbstractStatistics.java import org.jipijapa.management.spi.StatisticName; import org.jipijapa.management.spi.Statistics; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate4.management; /** * HibernateAbstractStatistics * * @author Scott Marlow */ public abstract class HibernateAbstractStatistics implements Statistics { private static final String RESOURCE_BUNDLE = HibernateAbstractStatistics.class.getPackage().getName() + ".LocalDescriptions"; private static final String RESOURCE_BUNDLE_KEY_PREFIX = "hibernate"; protected Map<String,Operation> operations = new HashMap<String, Operation>(); protected Set<String> childrenNames = new HashSet<String>(); protected Set<String> writeableNames = new HashSet<String>(); protected Map<String, Class> types = new HashMap<String, Class>(); protected Map<Locale, ResourceBundle> rbs = new HashMap<Locale, ResourceBundle>(); @Override public String getResourceBundleName() { return RESOURCE_BUNDLE; } @Override public String getResourceBundleKeyPrefix() { return RESOURCE_BUNDLE_KEY_PREFIX; } protected EntityManagerFactory getEntityManagerFactory(Object[] args) { PathAddress pathAddress = getPathAddress(args); for(Object arg :args) {
if (arg instanceof EntityManagerFactoryAccess) {
jipijapa/jipijapa
hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateAbstractStatistics.java
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/StatisticName.java // public interface StatisticName { // /** // * returns the statistic name // * @return // */ // String getName(); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // }
import org.jipijapa.management.spi.StatisticName; import org.jipijapa.management.spi.Statistics; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress;
} return null; } @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override public Class getType(String name) { return types.get(name); } @Override public boolean isOperation(String name) { return Operation.class.equals(getType(name)); } @Override public boolean isAttribute(String name) { return ! isOperation(name); } @Override public boolean isWriteable(String name) { return writeableNames.contains(name); } @Override
// Path: spi/src/main/java/org/jipijapa/management/spi/EntityManagerFactoryAccess.java // public interface EntityManagerFactoryAccess { // /** // * returns the entity manager factory that statistics should be obtained for. // * // * @throws IllegalStateException if scopedPersistenceUnitName is not found // * // * @param scopedPersistenceUnitName is persistence unit name scoped to the current platform // * // * @return EntityManagerFactory // */ // EntityManagerFactory entityManagerFactory(String scopedPersistenceUnitName) throws IllegalStateException; // // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Operation.java // public interface Operation { // // /** // * Invoke operation // * @param args will be passed to invoked operation // * @return // */ // Object invoke(Object... args); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/PathAddress.java // public interface PathAddress { // // int size(); // // String getValue(String name); // String getValue(int index); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/StatisticName.java // public interface StatisticName { // /** // * returns the statistic name // * @return // */ // String getName(); // } // // Path: spi/src/main/java/org/jipijapa/management/spi/Statistics.java // public interface Statistics { // // // /** // * Get the statistics names // * // * @return The value // */ // Set<String> getNames(); // // Collection<String> getDynamicChildrenNames(EntityManagerFactoryAccess entityManagerFactoryAccess, PathAddress pathAddress); // // /** // * Get the type // * // * @param name of the statistic // * @return The value // */ // Class getType(String name); // // /** // * return true if the specified name represents an operation. // * // * @param name of the statistic // * @return // */ // boolean isOperation(String name); // // /** // * return true if the specified name represents an attribute. // * // * @param name of the statistic // * @return // */ // boolean isAttribute(String name); // // /** // * return true if the specified name represents a writeable attribute // * @param name of the statistics // * @return // */ // boolean isWriteable(String name); // // /** // * for loading descriptions of statistics/operations // * // * @return name of resource bundle name // */ // String getResourceBundleName(); // // /** // * gets the key prefix for referencing descriptions of statistics/operations // * // * @return // */ // String getResourceBundleKeyPrefix(); // // /** // * Get the value of the statistics // * // * @param name The name of the statistics // * @return The value // */ // Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * Set the value of the statistic (isWriteable must return true) // * @param name // * @param newValue // */ // void setValue(String name, Object newValue, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress); // // /** // * get the names of the children statistic levels (if any) // * @return set of names // */ // Set<String> getChildrenNames(); // // /** // * get the specified children statistics // * @param childName name of the statistics to return // * @return // */ // Statistics getChild(String childName); // // // } // Path: hibernate4_3/src/main/java/org/jboss/as/jpa/hibernate4/management/HibernateAbstractStatistics.java import org.jipijapa.management.spi.StatisticName; import org.jipijapa.management.spi.Statistics; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import javax.persistence.EntityManagerFactory; import org.jipijapa.management.spi.EntityManagerFactoryAccess; import org.jipijapa.management.spi.Operation; import org.jipijapa.management.spi.PathAddress; } return null; } @Override public Set<String> getNames() { return Collections.unmodifiableSet(operations.keySet()); } @Override public Class getType(String name) { return types.get(name); } @Override public boolean isOperation(String name) { return Operation.class.equals(getType(name)); } @Override public boolean isAttribute(String name) { return ! isOperation(name); } @Override public boolean isWriteable(String name) { return writeableNames.contains(name); } @Override
public Object getValue(String name, EntityManagerFactoryAccess entityManagerFactoryAccess, StatisticName statisticName, PathAddress pathAddress) {
jipijapa/jipijapa
spi/src/main/java/org/jipijapa/event/impl/EventListenerRegistration.java
// Path: spi/src/main/java/org/jipijapa/event/impl/internal/Notification.java // public class Notification { // private static final CopyOnWriteArrayList<EventListener> eventListeners = new CopyOnWriteArrayList<EventListener>(); // // public static void add(EventListener eventListener) { // eventListeners.add(eventListener); // } // // public static void remove(EventListener eventListener) { // eventListeners.remove(eventListener); // } // // /** // * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // public static void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) { // for(EventListener eventListener: eventListeners) { // eventListener.beforeEntityManagerFactoryCreate(cacheType, persistenceUnitMetadata); // } // } // // /** // * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // public static void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) { // for(EventListener eventListener: eventListeners) { // eventListener.afterEntityManagerFactoryCreate(cacheType, persistenceUnitMetadata); // } // } // // /** // * start cache // * // * @param cacheType // * @param properties // * @return an opaque cache wrapper that is later passed to stopCache // */ // public static Wrapper startCache(Classification cacheType, Properties properties) throws Exception { // Wrapper result = null; // for(EventListener eventListener: eventListeners) { // Wrapper value = eventListener.startCache(cacheType, properties); // if (value != null && result == null) { // result = value; // return the first non-null wrapper value returned from a listener // } // } // // return result; // } // // /** // * add cache dependencies // * // * @param properties // */ // public static void addCacheDependencies(Classification cacheType, Properties properties) { // for(EventListener eventListener: eventListeners) { // eventListener.addCacheDependencies(cacheType, properties); // } // } // // /** // * Stop cache // * // * @param wrapper // * @param skipStop will be true if the cache shouldn't be stopped // */ // public static void stopCache(Classification cacheType, Wrapper wrapper, boolean skipStop) { // for(EventListener eventListener: eventListeners) { // eventListener.stopCache(cacheType, wrapper, skipStop); // } // } // // // } // // Path: spi/src/main/java/org/jipijapa/event/spi/EventListener.java // public interface EventListener { // // /** // * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param cacheType // * @param persistenceUnitMetadata // */ // void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * start cache // * // * @param cacheType // * @param properties // * @return an opaque cache wrapper that is later passed to stopCache // */ // Wrapper startCache(Classification cacheType, Properties properties) throws Exception; // // /** // * add dependencies on a cache // * // * @param cacheType // * @param properties // */ // void addCacheDependencies(Classification cacheType, Properties properties); // // /** // * Stop cache // * // * @param cacheType // * @param wrapper // * @param skipStop will be true if the cache shouldn't be stopped // */ // void stopCache(Classification cacheType, Wrapper wrapper, boolean skipStop); // }
import org.jipijapa.event.impl.internal.Notification; import org.jipijapa.event.spi.EventListener;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.event.impl; /** * System level EventListenerRegistration * * @author Scott Marlow */ public class EventListenerRegistration { public static void add(EventListener eventListener) {
// Path: spi/src/main/java/org/jipijapa/event/impl/internal/Notification.java // public class Notification { // private static final CopyOnWriteArrayList<EventListener> eventListeners = new CopyOnWriteArrayList<EventListener>(); // // public static void add(EventListener eventListener) { // eventListeners.add(eventListener); // } // // public static void remove(EventListener eventListener) { // eventListeners.remove(eventListener); // } // // /** // * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // public static void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) { // for(EventListener eventListener: eventListeners) { // eventListener.beforeEntityManagerFactoryCreate(cacheType, persistenceUnitMetadata); // } // } // // /** // * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // public static void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) { // for(EventListener eventListener: eventListeners) { // eventListener.afterEntityManagerFactoryCreate(cacheType, persistenceUnitMetadata); // } // } // // /** // * start cache // * // * @param cacheType // * @param properties // * @return an opaque cache wrapper that is later passed to stopCache // */ // public static Wrapper startCache(Classification cacheType, Properties properties) throws Exception { // Wrapper result = null; // for(EventListener eventListener: eventListeners) { // Wrapper value = eventListener.startCache(cacheType, properties); // if (value != null && result == null) { // result = value; // return the first non-null wrapper value returned from a listener // } // } // // return result; // } // // /** // * add cache dependencies // * // * @param properties // */ // public static void addCacheDependencies(Classification cacheType, Properties properties) { // for(EventListener eventListener: eventListeners) { // eventListener.addCacheDependencies(cacheType, properties); // } // } // // /** // * Stop cache // * // * @param wrapper // * @param skipStop will be true if the cache shouldn't be stopped // */ // public static void stopCache(Classification cacheType, Wrapper wrapper, boolean skipStop) { // for(EventListener eventListener: eventListeners) { // eventListener.stopCache(cacheType, wrapper, skipStop); // } // } // // // } // // Path: spi/src/main/java/org/jipijapa/event/spi/EventListener.java // public interface EventListener { // // /** // * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param cacheType // * @param persistenceUnitMetadata // */ // void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * start cache // * // * @param cacheType // * @param properties // * @return an opaque cache wrapper that is later passed to stopCache // */ // Wrapper startCache(Classification cacheType, Properties properties) throws Exception; // // /** // * add dependencies on a cache // * // * @param cacheType // * @param properties // */ // void addCacheDependencies(Classification cacheType, Properties properties); // // /** // * Stop cache // * // * @param cacheType // * @param wrapper // * @param skipStop will be true if the cache shouldn't be stopped // */ // void stopCache(Classification cacheType, Wrapper wrapper, boolean skipStop); // } // Path: spi/src/main/java/org/jipijapa/event/impl/EventListenerRegistration.java import org.jipijapa.event.impl.internal.Notification; import org.jipijapa.event.spi.EventListener; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.event.impl; /** * System level EventListenerRegistration * * @author Scott Marlow */ public class EventListenerRegistration { public static void add(EventListener eventListener) {
Notification.add(eventListener);
jipijapa/jipijapa
spi/src/main/java/org/jipijapa/event/impl/internal/Notification.java
// Path: spi/src/main/java/org/jipijapa/cache/spi/Classification.java // public enum Classification { // INFINISPAN("Infinispan"), // NONE(null); // // private final String name; // // Classification(final String name) { // this.name = name; // } // // /** // * Get the local name of this element. // * // * @return the local name // */ // public String getLocalName() { // return name; // } // // private static final Map<String, Classification> MAP; // // static { // final Map<String, Classification> map = new HashMap<String, Classification>(); // for (Classification element : values()) { // final String name = element.getLocalName(); // if (name != null) map.put(name, element); // } // MAP = map; // } // // public static Classification forName(String localName) { // final Classification element = MAP.get(localName); // return element == null ? NONE : element; // } // // } // // Path: spi/src/main/java/org/jipijapa/cache/spi/Wrapper.java // public interface Wrapper { // // Object getValue(); // // } // // Path: spi/src/main/java/org/jipijapa/event/spi/EventListener.java // public interface EventListener { // // /** // * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param cacheType // * @param persistenceUnitMetadata // */ // void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * start cache // * // * @param cacheType // * @param properties // * @return an opaque cache wrapper that is later passed to stopCache // */ // Wrapper startCache(Classification cacheType, Properties properties) throws Exception; // // /** // * add dependencies on a cache // * // * @param cacheType // * @param properties // */ // void addCacheDependencies(Classification cacheType, Properties properties); // // /** // * Stop cache // * // * @param cacheType // * @param wrapper // * @param skipStop will be true if the cache shouldn't be stopped // */ // void stopCache(Classification cacheType, Wrapper wrapper, boolean skipStop); // }
import java.util.Properties; import java.util.concurrent.CopyOnWriteArrayList; import org.jipijapa.cache.spi.Classification; import org.jipijapa.cache.spi.Wrapper; import org.jipijapa.event.spi.EventListener; import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.event.impl.internal; /** * Event Notification * * @author Scott Marlow */ public class Notification { private static final CopyOnWriteArrayList<EventListener> eventListeners = new CopyOnWriteArrayList<EventListener>(); public static void add(EventListener eventListener) { eventListeners.add(eventListener); } public static void remove(EventListener eventListener) { eventListeners.remove(eventListener); } /** * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param persistenceUnitMetadata */
// Path: spi/src/main/java/org/jipijapa/cache/spi/Classification.java // public enum Classification { // INFINISPAN("Infinispan"), // NONE(null); // // private final String name; // // Classification(final String name) { // this.name = name; // } // // /** // * Get the local name of this element. // * // * @return the local name // */ // public String getLocalName() { // return name; // } // // private static final Map<String, Classification> MAP; // // static { // final Map<String, Classification> map = new HashMap<String, Classification>(); // for (Classification element : values()) { // final String name = element.getLocalName(); // if (name != null) map.put(name, element); // } // MAP = map; // } // // public static Classification forName(String localName) { // final Classification element = MAP.get(localName); // return element == null ? NONE : element; // } // // } // // Path: spi/src/main/java/org/jipijapa/cache/spi/Wrapper.java // public interface Wrapper { // // Object getValue(); // // } // // Path: spi/src/main/java/org/jipijapa/event/spi/EventListener.java // public interface EventListener { // // /** // * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param cacheType // * @param persistenceUnitMetadata // */ // void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * start cache // * // * @param cacheType // * @param properties // * @return an opaque cache wrapper that is later passed to stopCache // */ // Wrapper startCache(Classification cacheType, Properties properties) throws Exception; // // /** // * add dependencies on a cache // * // * @param cacheType // * @param properties // */ // void addCacheDependencies(Classification cacheType, Properties properties); // // /** // * Stop cache // * // * @param cacheType // * @param wrapper // * @param skipStop will be true if the cache shouldn't be stopped // */ // void stopCache(Classification cacheType, Wrapper wrapper, boolean skipStop); // } // Path: spi/src/main/java/org/jipijapa/event/impl/internal/Notification.java import java.util.Properties; import java.util.concurrent.CopyOnWriteArrayList; import org.jipijapa.cache.spi.Classification; import org.jipijapa.cache.spi.Wrapper; import org.jipijapa.event.spi.EventListener; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.event.impl.internal; /** * Event Notification * * @author Scott Marlow */ public class Notification { private static final CopyOnWriteArrayList<EventListener> eventListeners = new CopyOnWriteArrayList<EventListener>(); public static void add(EventListener eventListener) { eventListeners.add(eventListener); } public static void remove(EventListener eventListener) { eventListeners.remove(eventListener); } /** * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param persistenceUnitMetadata */
public static void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) {
jipijapa/jipijapa
spi/src/main/java/org/jipijapa/event/impl/internal/Notification.java
// Path: spi/src/main/java/org/jipijapa/cache/spi/Classification.java // public enum Classification { // INFINISPAN("Infinispan"), // NONE(null); // // private final String name; // // Classification(final String name) { // this.name = name; // } // // /** // * Get the local name of this element. // * // * @return the local name // */ // public String getLocalName() { // return name; // } // // private static final Map<String, Classification> MAP; // // static { // final Map<String, Classification> map = new HashMap<String, Classification>(); // for (Classification element : values()) { // final String name = element.getLocalName(); // if (name != null) map.put(name, element); // } // MAP = map; // } // // public static Classification forName(String localName) { // final Classification element = MAP.get(localName); // return element == null ? NONE : element; // } // // } // // Path: spi/src/main/java/org/jipijapa/cache/spi/Wrapper.java // public interface Wrapper { // // Object getValue(); // // } // // Path: spi/src/main/java/org/jipijapa/event/spi/EventListener.java // public interface EventListener { // // /** // * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param cacheType // * @param persistenceUnitMetadata // */ // void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * start cache // * // * @param cacheType // * @param properties // * @return an opaque cache wrapper that is later passed to stopCache // */ // Wrapper startCache(Classification cacheType, Properties properties) throws Exception; // // /** // * add dependencies on a cache // * // * @param cacheType // * @param properties // */ // void addCacheDependencies(Classification cacheType, Properties properties); // // /** // * Stop cache // * // * @param cacheType // * @param wrapper // * @param skipStop will be true if the cache shouldn't be stopped // */ // void stopCache(Classification cacheType, Wrapper wrapper, boolean skipStop); // }
import java.util.Properties; import java.util.concurrent.CopyOnWriteArrayList; import org.jipijapa.cache.spi.Classification; import org.jipijapa.cache.spi.Wrapper; import org.jipijapa.event.spi.EventListener; import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.event.impl.internal; /** * Event Notification * * @author Scott Marlow */ public class Notification { private static final CopyOnWriteArrayList<EventListener> eventListeners = new CopyOnWriteArrayList<EventListener>(); public static void add(EventListener eventListener) { eventListeners.add(eventListener); } public static void remove(EventListener eventListener) { eventListeners.remove(eventListener); } /** * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param persistenceUnitMetadata */ public static void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) { for(EventListener eventListener: eventListeners) { eventListener.beforeEntityManagerFactoryCreate(cacheType, persistenceUnitMetadata); } } /** * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param persistenceUnitMetadata */ public static void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) { for(EventListener eventListener: eventListeners) { eventListener.afterEntityManagerFactoryCreate(cacheType, persistenceUnitMetadata); } } /** * start cache * * @param cacheType * @param properties * @return an opaque cache wrapper that is later passed to stopCache */
// Path: spi/src/main/java/org/jipijapa/cache/spi/Classification.java // public enum Classification { // INFINISPAN("Infinispan"), // NONE(null); // // private final String name; // // Classification(final String name) { // this.name = name; // } // // /** // * Get the local name of this element. // * // * @return the local name // */ // public String getLocalName() { // return name; // } // // private static final Map<String, Classification> MAP; // // static { // final Map<String, Classification> map = new HashMap<String, Classification>(); // for (Classification element : values()) { // final String name = element.getLocalName(); // if (name != null) map.put(name, element); // } // MAP = map; // } // // public static Classification forName(String localName) { // final Classification element = MAP.get(localName); // return element == null ? NONE : element; // } // // } // // Path: spi/src/main/java/org/jipijapa/cache/spi/Wrapper.java // public interface Wrapper { // // Object getValue(); // // } // // Path: spi/src/main/java/org/jipijapa/event/spi/EventListener.java // public interface EventListener { // // /** // * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param cacheType // * @param persistenceUnitMetadata // */ // void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) // * @param persistenceUnitMetadata // */ // void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); // // /** // * start cache // * // * @param cacheType // * @param properties // * @return an opaque cache wrapper that is later passed to stopCache // */ // Wrapper startCache(Classification cacheType, Properties properties) throws Exception; // // /** // * add dependencies on a cache // * // * @param cacheType // * @param properties // */ // void addCacheDependencies(Classification cacheType, Properties properties); // // /** // * Stop cache // * // * @param cacheType // * @param wrapper // * @param skipStop will be true if the cache shouldn't be stopped // */ // void stopCache(Classification cacheType, Wrapper wrapper, boolean skipStop); // } // Path: spi/src/main/java/org/jipijapa/event/impl/internal/Notification.java import java.util.Properties; import java.util.concurrent.CopyOnWriteArrayList; import org.jipijapa.cache.spi.Classification; import org.jipijapa.cache.spi.Wrapper; import org.jipijapa.event.spi.EventListener; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.event.impl.internal; /** * Event Notification * * @author Scott Marlow */ public class Notification { private static final CopyOnWriteArrayList<EventListener> eventListeners = new CopyOnWriteArrayList<EventListener>(); public static void add(EventListener eventListener) { eventListeners.add(eventListener); } public static void remove(EventListener eventListener) { eventListeners.remove(eventListener); } /** * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param persistenceUnitMetadata */ public static void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) { for(EventListener eventListener: eventListeners) { eventListener.beforeEntityManagerFactoryCreate(cacheType, persistenceUnitMetadata); } } /** * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param persistenceUnitMetadata */ public static void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata) { for(EventListener eventListener: eventListeners) { eventListener.afterEntityManagerFactoryCreate(cacheType, persistenceUnitMetadata); } } /** * start cache * * @param cacheType * @param properties * @return an opaque cache wrapper that is later passed to stopCache */
public static Wrapper startCache(Classification cacheType, Properties properties) throws Exception {
jipijapa/jipijapa
spi/src/main/java/org/jipijapa/event/spi/EventListener.java
// Path: spi/src/main/java/org/jipijapa/cache/spi/Classification.java // public enum Classification { // INFINISPAN("Infinispan"), // NONE(null); // // private final String name; // // Classification(final String name) { // this.name = name; // } // // /** // * Get the local name of this element. // * // * @return the local name // */ // public String getLocalName() { // return name; // } // // private static final Map<String, Classification> MAP; // // static { // final Map<String, Classification> map = new HashMap<String, Classification>(); // for (Classification element : values()) { // final String name = element.getLocalName(); // if (name != null) map.put(name, element); // } // MAP = map; // } // // public static Classification forName(String localName) { // final Classification element = MAP.get(localName); // return element == null ? NONE : element; // } // // } // // Path: spi/src/main/java/org/jipijapa/cache/spi/Wrapper.java // public interface Wrapper { // // Object getValue(); // // }
import java.util.Properties; import org.jipijapa.cache.spi.Classification; import org.jipijapa.cache.spi.Wrapper; import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.event.spi; /** * lifecycle EventListener * * @author Scott Marlow */ public interface EventListener { /** * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param cacheType * @param persistenceUnitMetadata */ void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); /** * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param persistenceUnitMetadata */ void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); /** * start cache * * @param cacheType * @param properties * @return an opaque cache wrapper that is later passed to stopCache */
// Path: spi/src/main/java/org/jipijapa/cache/spi/Classification.java // public enum Classification { // INFINISPAN("Infinispan"), // NONE(null); // // private final String name; // // Classification(final String name) { // this.name = name; // } // // /** // * Get the local name of this element. // * // * @return the local name // */ // public String getLocalName() { // return name; // } // // private static final Map<String, Classification> MAP; // // static { // final Map<String, Classification> map = new HashMap<String, Classification>(); // for (Classification element : values()) { // final String name = element.getLocalName(); // if (name != null) map.put(name, element); // } // MAP = map; // } // // public static Classification forName(String localName) { // final Classification element = MAP.get(localName); // return element == null ? NONE : element; // } // // } // // Path: spi/src/main/java/org/jipijapa/cache/spi/Wrapper.java // public interface Wrapper { // // Object getValue(); // // } // Path: spi/src/main/java/org/jipijapa/event/spi/EventListener.java import java.util.Properties; import org.jipijapa.cache.spi.Classification; import org.jipijapa.cache.spi.Wrapper; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jipijapa.event.spi; /** * lifecycle EventListener * * @author Scott Marlow */ public interface EventListener { /** * called before call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param cacheType * @param persistenceUnitMetadata */ void beforeEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); /** * called after call to PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnit, Map) * @param persistenceUnitMetadata */ void afterEntityManagerFactoryCreate(Classification cacheType, PersistenceUnitMetadata persistenceUnitMetadata); /** * start cache * * @param cacheType * @param properties * @return an opaque cache wrapper that is later passed to stopCache */
Wrapper startCache(Classification cacheType, Properties properties) throws Exception;
jipijapa/jipijapa
openjpa/src/main/java/org/jboss/as/jpa/openjpa/OpenJPAPersistenceProviderAdaptor.java
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // }
import java.util.Map; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.openjpa; /** * Implements the {@link PersistenceProviderAdaptor} for OpenJPA 2.x. * * @author Antti Laisi */ public class OpenJPAPersistenceProviderAdaptor implements PersistenceProviderAdaptor { private static final String TRANSACTION_MODE = "openjpa.TransactionMode"; private static final String MANAGED_RUNTIME = "openjpa.ManagedRuntime"; private static final String METADATA_FACTORY = "openjpa.MetaDataFactory"; @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) { if(!pu.getProperties().containsKey(TRANSACTION_MODE)) { properties.put(TRANSACTION_MODE, "managed"); } if(!pu.getProperties().containsKey(MANAGED_RUNTIME)) { properties.put(MANAGED_RUNTIME, "jndi(TransactionManagerName=java:jboss/TransactionManager)"); } if(!pu.getProperties().containsKey(METADATA_FACTORY)) { properties.put(METADATA_FACTORY, JBossPersistenceMetaDataFactory.class.getName()); } } @Override public void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { JBossPersistenceMetaDataFactory.setThreadLocalPersistenceUnitMetadata(pu); } @Override public void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { JBossPersistenceMetaDataFactory.clearThreadLocalPersistenceUnitMetadata(); } @Override public void injectJtaManager(JtaManager jtaManager) { } @Override
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // } // Path: openjpa/src/main/java/org/jboss/as/jpa/openjpa/OpenJPAPersistenceProviderAdaptor.java import java.util.Map; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.openjpa; /** * Implements the {@link PersistenceProviderAdaptor} for OpenJPA 2.x. * * @author Antti Laisi */ public class OpenJPAPersistenceProviderAdaptor implements PersistenceProviderAdaptor { private static final String TRANSACTION_MODE = "openjpa.TransactionMode"; private static final String MANAGED_RUNTIME = "openjpa.ManagedRuntime"; private static final String METADATA_FACTORY = "openjpa.MetaDataFactory"; @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) { if(!pu.getProperties().containsKey(TRANSACTION_MODE)) { properties.put(TRANSACTION_MODE, "managed"); } if(!pu.getProperties().containsKey(MANAGED_RUNTIME)) { properties.put(MANAGED_RUNTIME, "jndi(TransactionManagerName=java:jboss/TransactionManager)"); } if(!pu.getProperties().containsKey(METADATA_FACTORY)) { properties.put(METADATA_FACTORY, JBossPersistenceMetaDataFactory.class.getName()); } } @Override public void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { JBossPersistenceMetaDataFactory.setThreadLocalPersistenceUnitMetadata(pu); } @Override public void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { JBossPersistenceMetaDataFactory.clearThreadLocalPersistenceUnitMetadata(); } @Override public void injectJtaManager(JtaManager jtaManager) { } @Override
public void injectPlatform(Platform platform) {
jipijapa/jipijapa
openjpa/src/main/java/org/jboss/as/jpa/openjpa/OpenJPAPersistenceProviderAdaptor.java
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // }
import java.util.Map; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform;
properties.put(METADATA_FACTORY, JBossPersistenceMetaDataFactory.class.getName()); } } @Override public void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { JBossPersistenceMetaDataFactory.setThreadLocalPersistenceUnitMetadata(pu); } @Override public void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { JBossPersistenceMetaDataFactory.clearThreadLocalPersistenceUnitMetadata(); } @Override public void injectJtaManager(JtaManager jtaManager) { } @Override public void injectPlatform(Platform platform) { } @Override public void addProviderDependencies(PersistenceUnitMetadata pu) { } @Override
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // } // Path: openjpa/src/main/java/org/jboss/as/jpa/openjpa/OpenJPAPersistenceProviderAdaptor.java import java.util.Map; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform; properties.put(METADATA_FACTORY, JBossPersistenceMetaDataFactory.class.getName()); } } @Override public void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { JBossPersistenceMetaDataFactory.setThreadLocalPersistenceUnitMetadata(pu); } @Override public void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { JBossPersistenceMetaDataFactory.clearThreadLocalPersistenceUnitMetadata(); } @Override public void injectJtaManager(JtaManager jtaManager) { } @Override public void injectPlatform(Platform platform) { } @Override public void addProviderDependencies(PersistenceUnitMetadata pu) { } @Override
public ManagementAdaptor getManagementAdaptor() {
jipijapa/jipijapa
hibernate3/src/main/java/org/jboss/as/jpa/hibernate3/HibernatePersistenceProviderAdaptor.java
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // }
import java.lang.reflect.Method; import java.util.Map; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform;
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate3; /** * Implements the PersistenceProviderAdaptor for Hibernate 3.3.x or higher 3.x * * @author Scott Marlow */ public class HibernatePersistenceProviderAdaptor implements PersistenceProviderAdaptor { public static final String SCANNER = "hibernate.ejb.resource_scanner"; private static final String HIBERNATE_ANNOTATION_SCANNER_CLASS = "org.jboss.as.jpa.hibernate3.HibernateAnnotationScanner"; @Override public void injectJtaManager(JtaManager jtaManager) { JBossAppServerJtaPlatform.initJBossAppServerJtaPlatform(jtaManager); } @Override
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // } // Path: hibernate3/src/main/java/org/jboss/as/jpa/hibernate3/HibernatePersistenceProviderAdaptor.java import java.lang.reflect.Method; import java.util.Map; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform; /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Middleware LLC, 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.jboss.as.jpa.hibernate3; /** * Implements the PersistenceProviderAdaptor for Hibernate 3.3.x or higher 3.x * * @author Scott Marlow */ public class HibernatePersistenceProviderAdaptor implements PersistenceProviderAdaptor { public static final String SCANNER = "hibernate.ejb.resource_scanner"; private static final String HIBERNATE_ANNOTATION_SCANNER_CLASS = "org.jboss.as.jpa.hibernate3.HibernateAnnotationScanner"; @Override public void injectJtaManager(JtaManager jtaManager) { JBossAppServerJtaPlatform.initJBossAppServerJtaPlatform(jtaManager); } @Override
public void injectPlatform(Platform platform) {
jipijapa/jipijapa
hibernate3/src/main/java/org/jboss/as/jpa/hibernate3/HibernatePersistenceProviderAdaptor.java
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // }
import java.lang.reflect.Method; import java.util.Map; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform;
@Override public void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { if (pu.getProperties().containsKey(SCANNER)) { try { Class<?> scanner = Configuration.class.getClassLoader().loadClass(HIBERNATE_ANNOTATION_SCANNER_CLASS); // get method for public static void setThreadLocalPersistenceUnitMetadata(final PersistenceUnitMetadata pu) { Method setThreadLocalPersistenceUnitMetadata = scanner.getMethod("setThreadLocalPersistenceUnitMetadata", PersistenceUnitMetadata.class); setThreadLocalPersistenceUnitMetadata.invoke(null, pu); } catch (Throwable ignore) { } } } @Override public void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { if (pu.getProperties().containsKey(SCANNER)) { // clear backdoor annotation scanner access to pu try { Class<?> scanner = Configuration.class.getClassLoader().loadClass(HIBERNATE_ANNOTATION_SCANNER_CLASS); // get method for public static void clearThreadLocalPersistenceUnitMetadata() { Method clearThreadLocalPersistenceUnitMetadata = scanner.getMethod("clearThreadLocalPersistenceUnitMetadata"); clearThreadLocalPersistenceUnitMetadata.invoke(null); } catch (Throwable ignore) { } } } @Override
// Path: spi/src/main/java/org/jipijapa/plugin/spi/ManagementAdaptor.java // public interface ManagementAdaptor { // // // /** // * Get the short identification string that represents the management adaptor (e.g Hibernate) // * // * @return id label // */ // String getIdentificationLabel(); // // /** // * Version that uniquely identifies the management adapter (can be used to tell the difference between // * Hibernate 4.1 vs 4.3). // * // * @return version string // */ // String getVersion(); // // Statistics getStatistics(); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/PersistenceProviderAdaptor.java // public interface PersistenceProviderAdaptor { // // /** // * pass the JtaManager in for internal use by PersistenceProviderAdaptor implementer // * // * @param jtaManager // */ // void injectJtaManager(JtaManager jtaManager); // // /** // * pass the platform in use // * @param platform // */ // void injectPlatform(Platform platform); // // /** // * Adds any provider specific properties (e.g. hibernate.transaction.manager_lookup_class) // * // * @param properties // * @param pu // */ // void addProviderProperties(Map properties, PersistenceUnitMetadata pu); // // /** // * Persistence provider integration code might need dependencies that must be started // * for the deployment. Note that these dependency classes are expected to be already available to the provider. // * // * @param pu // * @return // */ // void addProviderDependencies(PersistenceUnitMetadata pu); // // /** // * Called right before persistence provider is invoked to create container entity manager factory. // * afterCreateContainerEntityManagerFactory() will always be called after the container entity manager factory // * is created. // * // * @param pu // */ // void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Called right after persistence provider is invoked to create container entity manager factory. // */ // void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu); // // /** // * Get the management adaptor // * // * @return ManagementAdaptor or null // */ // ManagementAdaptor getManagementAdaptor(); // // /** // * for adapters that support getManagementAdaptor(), does the scoped persistence unit name // * correctly identify cache entities. This is intended for Hibernate, other adapters can return true. // * // * @return the Hibernate adapter will return false if // * the persistence unit has specified a custom "hibernate.cache.region_prefix" property. True otherwise. // * // */ // boolean doesScopedPersistenceUnitNameIdentifyCacheRegionName(PersistenceUnitMetadata pu); // // /** // * Called when we are done with the persistence unit metadata // */ // void cleanup(PersistenceUnitMetadata pu); // } // // Path: spi/src/main/java/org/jipijapa/plugin/spi/Platform.java // public interface Platform { // // /** // * obtain the default second level cache classification // * @return default 2lc type // */ // Classification defaultCacheClassification(); // // /** // * get the second level cache classifications // * @return Set<Classification> // */ // Set<Classification> cacheClassifications(); // } // Path: hibernate3/src/main/java/org/jboss/as/jpa/hibernate3/HibernatePersistenceProviderAdaptor.java import java.lang.reflect.Method; import java.util.Map; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.jipijapa.plugin.spi.JtaManager; import org.jipijapa.plugin.spi.ManagementAdaptor; import org.jipijapa.plugin.spi.PersistenceProviderAdaptor; import org.jipijapa.plugin.spi.PersistenceUnitMetadata; import org.jipijapa.plugin.spi.Platform; @Override public void beforeCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { if (pu.getProperties().containsKey(SCANNER)) { try { Class<?> scanner = Configuration.class.getClassLoader().loadClass(HIBERNATE_ANNOTATION_SCANNER_CLASS); // get method for public static void setThreadLocalPersistenceUnitMetadata(final PersistenceUnitMetadata pu) { Method setThreadLocalPersistenceUnitMetadata = scanner.getMethod("setThreadLocalPersistenceUnitMetadata", PersistenceUnitMetadata.class); setThreadLocalPersistenceUnitMetadata.invoke(null, pu); } catch (Throwable ignore) { } } } @Override public void afterCreateContainerEntityManagerFactory(PersistenceUnitMetadata pu) { if (pu.getProperties().containsKey(SCANNER)) { // clear backdoor annotation scanner access to pu try { Class<?> scanner = Configuration.class.getClassLoader().loadClass(HIBERNATE_ANNOTATION_SCANNER_CLASS); // get method for public static void clearThreadLocalPersistenceUnitMetadata() { Method clearThreadLocalPersistenceUnitMetadata = scanner.getMethod("clearThreadLocalPersistenceUnitMetadata"); clearThreadLocalPersistenceUnitMetadata.invoke(null); } catch (Throwable ignore) { } } } @Override
public ManagementAdaptor getManagementAdaptor() {
allfro/BurpKit
src/main/java/com/redcanari/js/BurpExtenderCallbacksBridge.java
// Path: src/main/java/com/redcanari/js/wrappers/TextEditorWrapper.java // public class TextEditorWrapper implements ITextEditor { // // final ITextEditor textEditor; // byte[] text = null; // // public TextEditorWrapper(ITextEditor textEditor) { // this.textEditor = textEditor; // textEditor.getComponent().addHierarchyListener(e -> { // text = textEditor.getText(); // }); // } // // @Override // public Component getComponent() { // return textEditor.getComponent(); // } // // @Override // public void setEditable(boolean b) { // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setEditable(b)); // else // textEditor.setEditable(b); // } // // @Override // public void setText(byte[] bytes) { // text = bytes; // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setText(bytes)); // else // textEditor.setText(bytes); // } // // @Override // public byte[] getText() { // if (Platform.isFxApplicationThread()) // return text; // return textEditor.getText(); // } // // @Override // public boolean isTextModified() { // return textEditor.isTextModified(); // } // // @Override // public byte[] getSelectedText() { // return textEditor.getSelectedText(); // } // // @Override // public int[] getSelectionBounds() { // return textEditor.getSelectionBounds(); // } // // @Override // public void setSearchExpression(String s) { // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setSearchExpression(s)); // else // textEditor.setSearchExpression(s); // } // } // // Path: src/main/java/com/redcanari/swing/SwingFXUtilities.java // public class SwingFXUtilities { // // public static <T> void invokeLater(Callable<T> callable, JSObject callback) { // SwingUtilities.invokeLater(() -> { // try { // final T result = callable.call(); // if (callback != null) { // Platform.runLater(() -> callback.call("call", null, result)); // } // } catch (Exception e) { // e.printStackTrace(); // } // }); // } // // public static <T> T invokeAndWait(Callable<T> callable) throws TimeoutException, ExecutionException, InterruptedException { // //blocks until future returns // FutureTask<T> task = new FutureTask<>(callable); // SwingUtilities.invokeLater(task); // return task.get(); // } // // // // }
import burp.*; import com.redcanari.js.proxies.*; import com.redcanari.js.wrappers.TextEditorWrapper; import com.redcanari.swing.SwingFXUtilities; import javafx.scene.web.WebEngine; import netscape.javascript.JSObject; import javax.swing.*; import java.awt.*; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.net.CookieHandler; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException;
/** * This method is used to customize UI components in line with Burp's UI style, including font size, colors, table * line spacing, etc. The action is performed recursively on any child components of the passed-in component. * * @param component The UI component to be customized. */ public void customizeUiComponent(Component component) { SwingUtilities.invokeLater(() -> burpExtenderCallbacks.customizeUiComponent(component)); } /** * This method is used to create a new instance of Burp's HTTP message editor, for the extension to use in its own * UI. * * @param controller An object created by the extension that implements the {@link burp.IMessageEditorController} * interface. This parameter is optional and may be {@code null}. If it is provided, then the * message editor will query the controller when required to obtain details about the currently * displayed message, including the {@link burp.IHttpService} for the message, and the associated * request or response message. If a controller is not provided, then the message editor will not * support context menu actions, such as sending requests to other Burp tools. * @param editable Indicates whether the editor created should be editable, or used only for message viewing. * @param callback A JavaScript callback function that will be called once the {@link burp.IMessageEditor} * instance is created. The instance of {@link burp.IMessageEditor} will be passed to the callback * function as the first parameter. */ public void createMessageEditor(Object controller, boolean editable, JSObject callback) { final IMessageEditorController c = Helpers.<IMessageEditorController>wrapInterface(controller, MessageEditorControllerJSProxy.class);
// Path: src/main/java/com/redcanari/js/wrappers/TextEditorWrapper.java // public class TextEditorWrapper implements ITextEditor { // // final ITextEditor textEditor; // byte[] text = null; // // public TextEditorWrapper(ITextEditor textEditor) { // this.textEditor = textEditor; // textEditor.getComponent().addHierarchyListener(e -> { // text = textEditor.getText(); // }); // } // // @Override // public Component getComponent() { // return textEditor.getComponent(); // } // // @Override // public void setEditable(boolean b) { // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setEditable(b)); // else // textEditor.setEditable(b); // } // // @Override // public void setText(byte[] bytes) { // text = bytes; // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setText(bytes)); // else // textEditor.setText(bytes); // } // // @Override // public byte[] getText() { // if (Platform.isFxApplicationThread()) // return text; // return textEditor.getText(); // } // // @Override // public boolean isTextModified() { // return textEditor.isTextModified(); // } // // @Override // public byte[] getSelectedText() { // return textEditor.getSelectedText(); // } // // @Override // public int[] getSelectionBounds() { // return textEditor.getSelectionBounds(); // } // // @Override // public void setSearchExpression(String s) { // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setSearchExpression(s)); // else // textEditor.setSearchExpression(s); // } // } // // Path: src/main/java/com/redcanari/swing/SwingFXUtilities.java // public class SwingFXUtilities { // // public static <T> void invokeLater(Callable<T> callable, JSObject callback) { // SwingUtilities.invokeLater(() -> { // try { // final T result = callable.call(); // if (callback != null) { // Platform.runLater(() -> callback.call("call", null, result)); // } // } catch (Exception e) { // e.printStackTrace(); // } // }); // } // // public static <T> T invokeAndWait(Callable<T> callable) throws TimeoutException, ExecutionException, InterruptedException { // //blocks until future returns // FutureTask<T> task = new FutureTask<>(callable); // SwingUtilities.invokeLater(task); // return task.get(); // } // // // // } // Path: src/main/java/com/redcanari/js/BurpExtenderCallbacksBridge.java import burp.*; import com.redcanari.js.proxies.*; import com.redcanari.js.wrappers.TextEditorWrapper; import com.redcanari.swing.SwingFXUtilities; import javafx.scene.web.WebEngine; import netscape.javascript.JSObject; import javax.swing.*; import java.awt.*; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.net.CookieHandler; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; /** * This method is used to customize UI components in line with Burp's UI style, including font size, colors, table * line spacing, etc. The action is performed recursively on any child components of the passed-in component. * * @param component The UI component to be customized. */ public void customizeUiComponent(Component component) { SwingUtilities.invokeLater(() -> burpExtenderCallbacks.customizeUiComponent(component)); } /** * This method is used to create a new instance of Burp's HTTP message editor, for the extension to use in its own * UI. * * @param controller An object created by the extension that implements the {@link burp.IMessageEditorController} * interface. This parameter is optional and may be {@code null}. If it is provided, then the * message editor will query the controller when required to obtain details about the currently * displayed message, including the {@link burp.IHttpService} for the message, and the associated * request or response message. If a controller is not provided, then the message editor will not * support context menu actions, such as sending requests to other Burp tools. * @param editable Indicates whether the editor created should be editable, or used only for message viewing. * @param callback A JavaScript callback function that will be called once the {@link burp.IMessageEditor} * instance is created. The instance of {@link burp.IMessageEditor} will be passed to the callback * function as the first parameter. */ public void createMessageEditor(Object controller, boolean editable, JSObject callback) { final IMessageEditorController c = Helpers.<IMessageEditorController>wrapInterface(controller, MessageEditorControllerJSProxy.class);
SwingFXUtilities.invokeLater(
allfro/BurpKit
src/main/java/com/redcanari/js/BurpExtenderCallbacksBridge.java
// Path: src/main/java/com/redcanari/js/wrappers/TextEditorWrapper.java // public class TextEditorWrapper implements ITextEditor { // // final ITextEditor textEditor; // byte[] text = null; // // public TextEditorWrapper(ITextEditor textEditor) { // this.textEditor = textEditor; // textEditor.getComponent().addHierarchyListener(e -> { // text = textEditor.getText(); // }); // } // // @Override // public Component getComponent() { // return textEditor.getComponent(); // } // // @Override // public void setEditable(boolean b) { // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setEditable(b)); // else // textEditor.setEditable(b); // } // // @Override // public void setText(byte[] bytes) { // text = bytes; // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setText(bytes)); // else // textEditor.setText(bytes); // } // // @Override // public byte[] getText() { // if (Platform.isFxApplicationThread()) // return text; // return textEditor.getText(); // } // // @Override // public boolean isTextModified() { // return textEditor.isTextModified(); // } // // @Override // public byte[] getSelectedText() { // return textEditor.getSelectedText(); // } // // @Override // public int[] getSelectionBounds() { // return textEditor.getSelectionBounds(); // } // // @Override // public void setSearchExpression(String s) { // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setSearchExpression(s)); // else // textEditor.setSearchExpression(s); // } // } // // Path: src/main/java/com/redcanari/swing/SwingFXUtilities.java // public class SwingFXUtilities { // // public static <T> void invokeLater(Callable<T> callable, JSObject callback) { // SwingUtilities.invokeLater(() -> { // try { // final T result = callable.call(); // if (callback != null) { // Platform.runLater(() -> callback.call("call", null, result)); // } // } catch (Exception e) { // e.printStackTrace(); // } // }); // } // // public static <T> T invokeAndWait(Callable<T> callable) throws TimeoutException, ExecutionException, InterruptedException { // //blocks until future returns // FutureTask<T> task = new FutureTask<>(callable); // SwingUtilities.invokeLater(task); // return task.get(); // } // // // // }
import burp.*; import com.redcanari.js.proxies.*; import com.redcanari.js.wrappers.TextEditorWrapper; import com.redcanari.swing.SwingFXUtilities; import javafx.scene.web.WebEngine; import netscape.javascript.JSObject; import javax.swing.*; import java.awt.*; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.net.CookieHandler; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException;
* the extension and of Burp Suite. Saved settings can be retrieved using the method * {@link #loadExtensionSetting(String)}. * * @param name The name of the setting. * @param value The value of the setting. If this value is {@code null} then any existing setting with the specified * name will be removed. */ public void saveExtensionSetting(String name, String value) { SwingUtilities.invokeLater(() -> burpExtenderCallbacks.saveExtensionSetting(name, value)); } /** * This method is used to load configuration settings for the extension that were saved using the method * {@link #saveExtensionSetting(String, String)}. * * @param name The name of the setting. * @return The value of the setting, or {@code null} if no value is set. */ public String loadExtensionSetting(String name) throws InterruptedException, ExecutionException, TimeoutException { return SwingFXUtilities.invokeAndWait(() -> burpExtenderCallbacks.loadExtensionSetting(name)); } /** * This method is used to create a new instance of Burp's plain text editor, for the extension to use in its own UI. * * @return an instance of {@link burp.ITextEditor} */ public ITextEditor createTextEditor() {
// Path: src/main/java/com/redcanari/js/wrappers/TextEditorWrapper.java // public class TextEditorWrapper implements ITextEditor { // // final ITextEditor textEditor; // byte[] text = null; // // public TextEditorWrapper(ITextEditor textEditor) { // this.textEditor = textEditor; // textEditor.getComponent().addHierarchyListener(e -> { // text = textEditor.getText(); // }); // } // // @Override // public Component getComponent() { // return textEditor.getComponent(); // } // // @Override // public void setEditable(boolean b) { // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setEditable(b)); // else // textEditor.setEditable(b); // } // // @Override // public void setText(byte[] bytes) { // text = bytes; // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setText(bytes)); // else // textEditor.setText(bytes); // } // // @Override // public byte[] getText() { // if (Platform.isFxApplicationThread()) // return text; // return textEditor.getText(); // } // // @Override // public boolean isTextModified() { // return textEditor.isTextModified(); // } // // @Override // public byte[] getSelectedText() { // return textEditor.getSelectedText(); // } // // @Override // public int[] getSelectionBounds() { // return textEditor.getSelectionBounds(); // } // // @Override // public void setSearchExpression(String s) { // if (Platform.isFxApplicationThread()) // SwingUtilities.invokeLater(() -> textEditor.setSearchExpression(s)); // else // textEditor.setSearchExpression(s); // } // } // // Path: src/main/java/com/redcanari/swing/SwingFXUtilities.java // public class SwingFXUtilities { // // public static <T> void invokeLater(Callable<T> callable, JSObject callback) { // SwingUtilities.invokeLater(() -> { // try { // final T result = callable.call(); // if (callback != null) { // Platform.runLater(() -> callback.call("call", null, result)); // } // } catch (Exception e) { // e.printStackTrace(); // } // }); // } // // public static <T> T invokeAndWait(Callable<T> callable) throws TimeoutException, ExecutionException, InterruptedException { // //blocks until future returns // FutureTask<T> task = new FutureTask<>(callable); // SwingUtilities.invokeLater(task); // return task.get(); // } // // // // } // Path: src/main/java/com/redcanari/js/BurpExtenderCallbacksBridge.java import burp.*; import com.redcanari.js.proxies.*; import com.redcanari.js.wrappers.TextEditorWrapper; import com.redcanari.swing.SwingFXUtilities; import javafx.scene.web.WebEngine; import netscape.javascript.JSObject; import javax.swing.*; import java.awt.*; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.net.CookieHandler; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; * the extension and of Burp Suite. Saved settings can be retrieved using the method * {@link #loadExtensionSetting(String)}. * * @param name The name of the setting. * @param value The value of the setting. If this value is {@code null} then any existing setting with the specified * name will be removed. */ public void saveExtensionSetting(String name, String value) { SwingUtilities.invokeLater(() -> burpExtenderCallbacks.saveExtensionSetting(name, value)); } /** * This method is used to load configuration settings for the extension that were saved using the method * {@link #saveExtensionSetting(String, String)}. * * @param name The name of the setting. * @return The value of the setting, or {@code null} if no value is set. */ public String loadExtensionSetting(String name) throws InterruptedException, ExecutionException, TimeoutException { return SwingFXUtilities.invokeAndWait(() -> burpExtenderCallbacks.loadExtensionSetting(name)); } /** * This method is used to create a new instance of Burp's plain text editor, for the extension to use in its own UI. * * @return an instance of {@link burp.ITextEditor} */ public ITextEditor createTextEditor() {
return new TextEditorWrapper(burpExtenderCallbacks.createTextEditor());
allfro/BurpKit
src/main/java/com/dlsc/trafficbrowser/scene/layout/TrafficTimeline.java
// Path: src/main/java/com/dlsc/trafficbrowser/scene/control/TrafficBrowser.java // public class TrafficBrowser extends Control { // // public TrafficBrowser() { // getStylesheets().add( // TrafficBrowser.class. // getResource("/stylesheets/traffic.css").toExternalForm() // ); // } // // @Override // protected Skin<TrafficBrowser> createDefaultSkin() { // return new TrafficBrowserSkin(this); // } // // private final ObjectProperty<Instant> startTime = new SimpleObjectProperty<>(this, "startTime", Instant.now()); // // public final ObjectProperty<Instant> startTimeProperty() { // return startTime; // } // // public final Instant getStartTime() { // return startTimeProperty().get(); // } // // public final void setStartTime(Instant time) { // startTimeProperty().set(time); // } // // private final ObjectProperty<Instant> endTime = new SimpleObjectProperty<>(this, "endTime", Instant.now()); // // public final ObjectProperty<Instant> endTimeProperty() { // return endTime; // } // // public final Instant getEndTime() { // return endTimeProperty().get(); // } // // public final void setEndTime(Instant time) { // endTimeProperty().set(time); // } // // private ObservableList<Traffic> traffic = FXCollections.observableArrayList(); // // public ObservableList<Traffic> getTraffic() { // return traffic; // } // }
import com.dlsc.trafficbrowser.beans.Traffic; import com.dlsc.trafficbrowser.scene.control.TrafficBrowser; import javafx.scene.layout.Pane; import javafx.scene.layout.Region; import java.time.Instant;
/* * BurpKit - WebKit-based penetration testing plugin for BurpSuite * Copyright (C) 2015 Red Canari, Inc. * * 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 3 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, see <http://www.gnu.org/licenses/>. */ package com.dlsc.trafficbrowser.scene.layout; /** * @author Dirk Lemmermann * @since 2015-01-24 * @version 1.0 */ public class TrafficTimeline extends Pane { private Region timebar = new Region(); private Traffic traffic;
// Path: src/main/java/com/dlsc/trafficbrowser/scene/control/TrafficBrowser.java // public class TrafficBrowser extends Control { // // public TrafficBrowser() { // getStylesheets().add( // TrafficBrowser.class. // getResource("/stylesheets/traffic.css").toExternalForm() // ); // } // // @Override // protected Skin<TrafficBrowser> createDefaultSkin() { // return new TrafficBrowserSkin(this); // } // // private final ObjectProperty<Instant> startTime = new SimpleObjectProperty<>(this, "startTime", Instant.now()); // // public final ObjectProperty<Instant> startTimeProperty() { // return startTime; // } // // public final Instant getStartTime() { // return startTimeProperty().get(); // } // // public final void setStartTime(Instant time) { // startTimeProperty().set(time); // } // // private final ObjectProperty<Instant> endTime = new SimpleObjectProperty<>(this, "endTime", Instant.now()); // // public final ObjectProperty<Instant> endTimeProperty() { // return endTime; // } // // public final Instant getEndTime() { // return endTimeProperty().get(); // } // // public final void setEndTime(Instant time) { // endTimeProperty().set(time); // } // // private ObservableList<Traffic> traffic = FXCollections.observableArrayList(); // // public ObservableList<Traffic> getTraffic() { // return traffic; // } // } // Path: src/main/java/com/dlsc/trafficbrowser/scene/layout/TrafficTimeline.java import com.dlsc.trafficbrowser.beans.Traffic; import com.dlsc.trafficbrowser.scene.control.TrafficBrowser; import javafx.scene.layout.Pane; import javafx.scene.layout.Region; import java.time.Instant; /* * BurpKit - WebKit-based penetration testing plugin for BurpSuite * Copyright (C) 2015 Red Canari, Inc. * * 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 3 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, see <http://www.gnu.org/licenses/>. */ package com.dlsc.trafficbrowser.scene.layout; /** * @author Dirk Lemmermann * @since 2015-01-24 * @version 1.0 */ public class TrafficTimeline extends Pane { private Region timebar = new Region(); private Traffic traffic;
private TrafficBrowser browser;
allfro/BurpKit
src/main/java/burp/BurpScriptTab.java
// Path: src/main/java/com/redcanari/ui/JavaScriptEditorTab.java // public class JavaScriptEditorTab extends JFXPanel { // // public JavaScriptEditorTab() { // Platform.runLater(this::init); // } // // private void init() { // JavaScriptEditor javaScriptEditor = new JavaScriptEditor(); // setScene(new Scene(javaScriptEditor)); // } // }
import com.redcanari.ui.JavaScriptEditorTab; import java.awt.*;
/* * BurpKit - WebKit-based penetration testing plugin for BurpSuite * Copyright (C) 2015 Red Canari, Inc. * * 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 3 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, see <http://www.gnu.org/licenses/>. */ package burp; /** * Created by ndouba on 15-06-18. */ public class BurpScriptTab implements ITab { @Override public String getTabCaption() { return "BurpScript IDE"; } @Override public Component getUiComponent() {
// Path: src/main/java/com/redcanari/ui/JavaScriptEditorTab.java // public class JavaScriptEditorTab extends JFXPanel { // // public JavaScriptEditorTab() { // Platform.runLater(this::init); // } // // private void init() { // JavaScriptEditor javaScriptEditor = new JavaScriptEditor(); // setScene(new Scene(javaScriptEditor)); // } // } // Path: src/main/java/burp/BurpScriptTab.java import com.redcanari.ui.JavaScriptEditorTab; import java.awt.*; /* * BurpKit - WebKit-based penetration testing plugin for BurpSuite * Copyright (C) 2015 Red Canari, Inc. * * 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 3 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, see <http://www.gnu.org/licenses/>. */ package burp; /** * Created by ndouba on 15-06-18. */ public class BurpScriptTab implements ITab { @Override public String getTabCaption() { return "BurpScript IDE"; } @Override public Component getUiComponent() {
return new JavaScriptEditorTab();
allfro/BurpKit
src/main/java/com/redcanari/js/BurpKitBridge.java
// Path: src/main/java/com/redcanari/ui/JSLoginDialog.java // public class JSLoginDialog extends Dialog<Pair<String, String>> { // // private final TextField username; // // public JSLoginDialog() { // setTitle("Login Dialog"); // // // Set the icon (must be included in the project). // // setGraphic(new ImageView(this.getClass().getResource("login.png").toString())); // // // Set the button types. // ButtonType loginButtonType = new ButtonType("Login", ButtonBar.ButtonData.OK_DONE); // getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // // // Create the username and password labels and fields. // GridPane grid = new GridPane(); // grid.setHgap(10); // grid.setVgap(10); // grid.setPadding(new Insets(20, 150, 10, 10)); // // username = new TextField(); // username.setPromptText("Username"); // PasswordField password = new PasswordField(); // password.setPromptText("Password"); // // grid.add(new Label("Username:"), 0, 0); // grid.add(username, 1, 0); // grid.add(new Label("Password:"), 0, 1); // grid.add(password, 1, 1); // // // Enable/Disable login button depending on whether a username was entered. // Node loginButton = getDialogPane().lookupButton(loginButtonType); // // loginButton.setDisable(true); // // // Do some validation (using the Java 8 lambda syntax). // // username.textProperty().addListener((observable, oldValue, newValue) -> { // // loginButton.setDisable(newValue.trim().isEmpty()); // // }); // // getDialogPane().setContent(grid); // // // Convert the result to a username-password-pair when the login button is clicked. // setResultConverter(dialogButton -> { // if (dialogButton == loginButtonType) { // return new Pair<>(username.getText(), password.getText()); // } // return null; // }); // } // // public Pair<String, String> login(String loginPrompt) { // // Set the masthead to the user's prompt message. // setHeaderText(loginPrompt); // // // Request focus on the textfield so the user can type their response right away. // // Request focus on the username field by default. // Platform.runLater(username::requestFocus); // // // Show and wait for the result and then return a string or null // Optional<Pair<String, String>> result = super.showAndWait(); // return (result.isPresent())?result.get():null; // } // } // // Path: src/main/java/com/redcanari/util/ResourceUtils.java // public class ResourceUtils { // // public static String getResourceContentsAsString(String filename) { // InputStream inputStream = ResourceUtils.class.getResourceAsStream(filename); // return new Scanner(inputStream).useDelimiter("\\Z").next(); // } // }
import com.redcanari.ui.JSInputDialog; import com.redcanari.ui.JSLoginDialog; import com.redcanari.util.ResourceUtils; import javafx.application.Platform; import javafx.scene.web.PromptData; import javafx.scene.web.WebEngine; import javafx.stage.FileChooser; import javafx.util.Pair; import netscape.javascript.JSObject; import javax.swing.*; import java.io.File; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.List; import java.util.Optional;
/* * BurpKit - WebKit-based penetration testing plugin for BurpSuite * Copyright (C) 2015 Red Canari, Inc. * * 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 3 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, see <http://www.gnu.org/licenses/>. */ package com.redcanari.js; /** * Created by ndouba on 15-05-16. */ public class BurpKitBridge { private final LocalJSObject locals; private final LocalJSObject globals; private final WebEngine webEngine; public BurpKitBridge(WebEngine webEngine) { this.webEngine = webEngine; globals = GlobalJSObject.getGlobalJSObject(webEngine); locals = new LocalJSObject(webEngine); } public byte[] httpGetBytes(String url) throws IOException { URLConnection uc = new URL(url).openConnection(); uc.setRequestProperty("User-Agent", webEngine.getUserAgent()); return Helpers.convertStreamToBytes(uc.getInputStream()); } public String httpGetString(String url) throws IOException { URLConnection uc = new URL(url).openConnection(); uc.setRequestProperty("User-Agent", webEngine.getUserAgent()); return Helpers.convertStreamToString(uc.getInputStream()); } public void require(String url) throws IOException { webEngine.executeScript(httpGetString(url)); } public void requireLib(String library) throws IOException { webEngine.executeScript(
// Path: src/main/java/com/redcanari/ui/JSLoginDialog.java // public class JSLoginDialog extends Dialog<Pair<String, String>> { // // private final TextField username; // // public JSLoginDialog() { // setTitle("Login Dialog"); // // // Set the icon (must be included in the project). // // setGraphic(new ImageView(this.getClass().getResource("login.png").toString())); // // // Set the button types. // ButtonType loginButtonType = new ButtonType("Login", ButtonBar.ButtonData.OK_DONE); // getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // // // Create the username and password labels and fields. // GridPane grid = new GridPane(); // grid.setHgap(10); // grid.setVgap(10); // grid.setPadding(new Insets(20, 150, 10, 10)); // // username = new TextField(); // username.setPromptText("Username"); // PasswordField password = new PasswordField(); // password.setPromptText("Password"); // // grid.add(new Label("Username:"), 0, 0); // grid.add(username, 1, 0); // grid.add(new Label("Password:"), 0, 1); // grid.add(password, 1, 1); // // // Enable/Disable login button depending on whether a username was entered. // Node loginButton = getDialogPane().lookupButton(loginButtonType); // // loginButton.setDisable(true); // // // Do some validation (using the Java 8 lambda syntax). // // username.textProperty().addListener((observable, oldValue, newValue) -> { // // loginButton.setDisable(newValue.trim().isEmpty()); // // }); // // getDialogPane().setContent(grid); // // // Convert the result to a username-password-pair when the login button is clicked. // setResultConverter(dialogButton -> { // if (dialogButton == loginButtonType) { // return new Pair<>(username.getText(), password.getText()); // } // return null; // }); // } // // public Pair<String, String> login(String loginPrompt) { // // Set the masthead to the user's prompt message. // setHeaderText(loginPrompt); // // // Request focus on the textfield so the user can type their response right away. // // Request focus on the username field by default. // Platform.runLater(username::requestFocus); // // // Show and wait for the result and then return a string or null // Optional<Pair<String, String>> result = super.showAndWait(); // return (result.isPresent())?result.get():null; // } // } // // Path: src/main/java/com/redcanari/util/ResourceUtils.java // public class ResourceUtils { // // public static String getResourceContentsAsString(String filename) { // InputStream inputStream = ResourceUtils.class.getResourceAsStream(filename); // return new Scanner(inputStream).useDelimiter("\\Z").next(); // } // } // Path: src/main/java/com/redcanari/js/BurpKitBridge.java import com.redcanari.ui.JSInputDialog; import com.redcanari.ui.JSLoginDialog; import com.redcanari.util.ResourceUtils; import javafx.application.Platform; import javafx.scene.web.PromptData; import javafx.scene.web.WebEngine; import javafx.stage.FileChooser; import javafx.util.Pair; import netscape.javascript.JSObject; import javax.swing.*; import java.io.File; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.List; import java.util.Optional; /* * BurpKit - WebKit-based penetration testing plugin for BurpSuite * Copyright (C) 2015 Red Canari, Inc. * * 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 3 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, see <http://www.gnu.org/licenses/>. */ package com.redcanari.js; /** * Created by ndouba on 15-05-16. */ public class BurpKitBridge { private final LocalJSObject locals; private final LocalJSObject globals; private final WebEngine webEngine; public BurpKitBridge(WebEngine webEngine) { this.webEngine = webEngine; globals = GlobalJSObject.getGlobalJSObject(webEngine); locals = new LocalJSObject(webEngine); } public byte[] httpGetBytes(String url) throws IOException { URLConnection uc = new URL(url).openConnection(); uc.setRequestProperty("User-Agent", webEngine.getUserAgent()); return Helpers.convertStreamToBytes(uc.getInputStream()); } public String httpGetString(String url) throws IOException { URLConnection uc = new URL(url).openConnection(); uc.setRequestProperty("User-Agent", webEngine.getUserAgent()); return Helpers.convertStreamToString(uc.getInputStream()); } public void require(String url) throws IOException { webEngine.executeScript(httpGetString(url)); } public void requireLib(String library) throws IOException { webEngine.executeScript(
ResourceUtils.getResourceContentsAsString("/scripts/" + library + ".js")
allfro/BurpKit
src/main/java/com/redcanari/js/BurpKitBridge.java
// Path: src/main/java/com/redcanari/ui/JSLoginDialog.java // public class JSLoginDialog extends Dialog<Pair<String, String>> { // // private final TextField username; // // public JSLoginDialog() { // setTitle("Login Dialog"); // // // Set the icon (must be included in the project). // // setGraphic(new ImageView(this.getClass().getResource("login.png").toString())); // // // Set the button types. // ButtonType loginButtonType = new ButtonType("Login", ButtonBar.ButtonData.OK_DONE); // getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // // // Create the username and password labels and fields. // GridPane grid = new GridPane(); // grid.setHgap(10); // grid.setVgap(10); // grid.setPadding(new Insets(20, 150, 10, 10)); // // username = new TextField(); // username.setPromptText("Username"); // PasswordField password = new PasswordField(); // password.setPromptText("Password"); // // grid.add(new Label("Username:"), 0, 0); // grid.add(username, 1, 0); // grid.add(new Label("Password:"), 0, 1); // grid.add(password, 1, 1); // // // Enable/Disable login button depending on whether a username was entered. // Node loginButton = getDialogPane().lookupButton(loginButtonType); // // loginButton.setDisable(true); // // // Do some validation (using the Java 8 lambda syntax). // // username.textProperty().addListener((observable, oldValue, newValue) -> { // // loginButton.setDisable(newValue.trim().isEmpty()); // // }); // // getDialogPane().setContent(grid); // // // Convert the result to a username-password-pair when the login button is clicked. // setResultConverter(dialogButton -> { // if (dialogButton == loginButtonType) { // return new Pair<>(username.getText(), password.getText()); // } // return null; // }); // } // // public Pair<String, String> login(String loginPrompt) { // // Set the masthead to the user's prompt message. // setHeaderText(loginPrompt); // // // Request focus on the textfield so the user can type their response right away. // // Request focus on the username field by default. // Platform.runLater(username::requestFocus); // // // Show and wait for the result and then return a string or null // Optional<Pair<String, String>> result = super.showAndWait(); // return (result.isPresent())?result.get():null; // } // } // // Path: src/main/java/com/redcanari/util/ResourceUtils.java // public class ResourceUtils { // // public static String getResourceContentsAsString(String filename) { // InputStream inputStream = ResourceUtils.class.getResourceAsStream(filename); // return new Scanner(inputStream).useDelimiter("\\Z").next(); // } // }
import com.redcanari.ui.JSInputDialog; import com.redcanari.ui.JSLoginDialog; import com.redcanari.util.ResourceUtils; import javafx.application.Platform; import javafx.scene.web.PromptData; import javafx.scene.web.WebEngine; import javafx.stage.FileChooser; import javafx.util.Pair; import netscape.javascript.JSObject; import javax.swing.*; import java.io.File; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.List; import java.util.Optional;
return (file == null)?null:file.toString(); } public String openFileDialog(String title) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(title); File file = fileChooser.showOpenDialog(null); return (file == null)?null:file.toString(); } public JSObject openMultipleDialog(String title) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(title); List<File> files = fileChooser.showOpenMultipleDialog(null); return (files == null)? (JSObject) webEngine.executeScript("new Array") :Helpers.toJSArray(webEngine, files); } public void writeToFile(String file, String data) throws IOException { Files.write(new File(file).toPath(), data.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } public String readFromFile(String file) throws IOException { return new String(Files.readAllBytes(new File(file).toPath())); } public void appendToFile(String file, String data) throws IOException { Files.write(new File(file).toPath(), data.getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } public void loginPrompt(JSObject callback) {
// Path: src/main/java/com/redcanari/ui/JSLoginDialog.java // public class JSLoginDialog extends Dialog<Pair<String, String>> { // // private final TextField username; // // public JSLoginDialog() { // setTitle("Login Dialog"); // // // Set the icon (must be included in the project). // // setGraphic(new ImageView(this.getClass().getResource("login.png").toString())); // // // Set the button types. // ButtonType loginButtonType = new ButtonType("Login", ButtonBar.ButtonData.OK_DONE); // getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // // // Create the username and password labels and fields. // GridPane grid = new GridPane(); // grid.setHgap(10); // grid.setVgap(10); // grid.setPadding(new Insets(20, 150, 10, 10)); // // username = new TextField(); // username.setPromptText("Username"); // PasswordField password = new PasswordField(); // password.setPromptText("Password"); // // grid.add(new Label("Username:"), 0, 0); // grid.add(username, 1, 0); // grid.add(new Label("Password:"), 0, 1); // grid.add(password, 1, 1); // // // Enable/Disable login button depending on whether a username was entered. // Node loginButton = getDialogPane().lookupButton(loginButtonType); // // loginButton.setDisable(true); // // // Do some validation (using the Java 8 lambda syntax). // // username.textProperty().addListener((observable, oldValue, newValue) -> { // // loginButton.setDisable(newValue.trim().isEmpty()); // // }); // // getDialogPane().setContent(grid); // // // Convert the result to a username-password-pair when the login button is clicked. // setResultConverter(dialogButton -> { // if (dialogButton == loginButtonType) { // return new Pair<>(username.getText(), password.getText()); // } // return null; // }); // } // // public Pair<String, String> login(String loginPrompt) { // // Set the masthead to the user's prompt message. // setHeaderText(loginPrompt); // // // Request focus on the textfield so the user can type their response right away. // // Request focus on the username field by default. // Platform.runLater(username::requestFocus); // // // Show and wait for the result and then return a string or null // Optional<Pair<String, String>> result = super.showAndWait(); // return (result.isPresent())?result.get():null; // } // } // // Path: src/main/java/com/redcanari/util/ResourceUtils.java // public class ResourceUtils { // // public static String getResourceContentsAsString(String filename) { // InputStream inputStream = ResourceUtils.class.getResourceAsStream(filename); // return new Scanner(inputStream).useDelimiter("\\Z").next(); // } // } // Path: src/main/java/com/redcanari/js/BurpKitBridge.java import com.redcanari.ui.JSInputDialog; import com.redcanari.ui.JSLoginDialog; import com.redcanari.util.ResourceUtils; import javafx.application.Platform; import javafx.scene.web.PromptData; import javafx.scene.web.WebEngine; import javafx.stage.FileChooser; import javafx.util.Pair; import netscape.javascript.JSObject; import javax.swing.*; import java.io.File; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.List; import java.util.Optional; return (file == null)?null:file.toString(); } public String openFileDialog(String title) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(title); File file = fileChooser.showOpenDialog(null); return (file == null)?null:file.toString(); } public JSObject openMultipleDialog(String title) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(title); List<File> files = fileChooser.showOpenMultipleDialog(null); return (files == null)? (JSObject) webEngine.executeScript("new Array") :Helpers.toJSArray(webEngine, files); } public void writeToFile(String file, String data) throws IOException { Files.write(new File(file).toPath(), data.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } public String readFromFile(String file) throws IOException { return new String(Files.readAllBytes(new File(file).toPath())); } public void appendToFile(String file, String data) throws IOException { Files.write(new File(file).toPath(), data.getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } public void loginPrompt(JSObject callback) {
Pair<String, String> result = new JSLoginDialog().login("Login");
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/complex/ComplexBase.java
// Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // }
import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey; import com.healthmarketscience.jackcess.impl.complex.ComplexColumnInfoImpl; import java.io.IOException; import java.io.Serializable; import java.util.List; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import com.healthmarketscience.jackcess.complex.ComplexDataType; import com.healthmarketscience.jackcess.complex.ComplexValue;
result = prime * result + id; result = prime * result + ((tableName == null) ? 0 : tableName.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ComplexBase other = (ComplexBase) obj; if (columnName == null) { if (other.columnName != null) return false; } else if (!columnName.equals(other.columnName)) return false; if (id != other.id) return false; if (tableName == null) { if (other.tableName != null) return false; } else if (!tableName.equals(other.tableName)) return false; return true; } public final static Object[] convert(ComplexValueForeignKey fk)
// Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // Path: src/main/java/net/ucanaccess/complex/ComplexBase.java import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey; import com.healthmarketscience.jackcess.impl.complex.ComplexColumnInfoImpl; import java.io.IOException; import java.io.Serializable; import java.util.List; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import com.healthmarketscience.jackcess.complex.ComplexDataType; import com.healthmarketscience.jackcess.complex.ComplexValue; result = prime * result + id; result = prime * result + ((tableName == null) ? 0 : tableName.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ComplexBase other = (ComplexBase) obj; if (columnName == null) { if (other.columnName != null) return false; } else if (!columnName.equals(other.columnName)) return false; if (id != other.id) return false; if (tableName == null) { if (other.tableName != null) return false; } else if (!tableName.equals(other.tableName)) return false; return true; } public final static Object[] convert(ComplexValueForeignKey fk)
throws IOException, UcanaccessSQLException {
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/complex/ComplexBase.java
// Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // }
import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey; import com.healthmarketscience.jackcess.impl.complex.ComplexColumnInfoImpl; import java.io.IOException; import java.io.Serializable; import java.util.List; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import com.healthmarketscience.jackcess.complex.ComplexDataType; import com.healthmarketscience.jackcess.complex.ComplexValue;
return lat; } if (fk.getComplexType().equals(ComplexDataType.MULTI_VALUE)) { List<com.healthmarketscience.jackcess.complex.SingleValue> lst = fk .getMultiValues(); SingleValue[] lat = new SingleValue[lst.size()]; for (int i = 0; i < lat.length; i++) { lat[i] = new SingleValue(lst.get(i)); } return lat; } if (fk.getComplexType().equals(ComplexDataType.VERSION_HISTORY)) { List<com.healthmarketscience.jackcess.complex.Version> lst = fk .getVersions(); Version[] lat = new Version[lst.size()]; for (int i = 0; i < lat.length; i++) { lat[i] = new Version(lst.get(i)); } return lat; } if (fk.getComplexType().equals(ComplexDataType.UNSUPPORTED)) { List<com.healthmarketscience.jackcess.complex.UnsupportedValue> lst = fk .getUnsupportedValues(); UnsupportedValue[] lat = new UnsupportedValue[lst.size()]; for (int i = 0; i < lat.length; i++) { lat[i] = new UnsupportedValue(lst.get(i)); } return lat; }
// Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // Path: src/main/java/net/ucanaccess/complex/ComplexBase.java import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey; import com.healthmarketscience.jackcess.impl.complex.ComplexColumnInfoImpl; import java.io.IOException; import java.io.Serializable; import java.util.List; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import com.healthmarketscience.jackcess.complex.ComplexDataType; import com.healthmarketscience.jackcess.complex.ComplexValue; return lat; } if (fk.getComplexType().equals(ComplexDataType.MULTI_VALUE)) { List<com.healthmarketscience.jackcess.complex.SingleValue> lst = fk .getMultiValues(); SingleValue[] lat = new SingleValue[lst.size()]; for (int i = 0; i < lat.length; i++) { lat[i] = new SingleValue(lst.get(i)); } return lat; } if (fk.getComplexType().equals(ComplexDataType.VERSION_HISTORY)) { List<com.healthmarketscience.jackcess.complex.Version> lst = fk .getVersions(); Version[] lat = new Version[lst.size()]; for (int i = 0; i < lat.length; i++) { lat[i] = new Version(lst.get(i)); } return lat; } if (fk.getComplexType().equals(ComplexDataType.UNSUPPORTED)) { List<com.healthmarketscience.jackcess.complex.UnsupportedValue> lst = fk .getUnsupportedValues(); UnsupportedValue[] lat = new UnsupportedValue[lst.size()]; for (int i = 0; i < lat.length; i++) { lat[i] = new UnsupportedValue(lst.get(i)); } return lat; }
throw new UcanaccessSQLException(ExceptionMessages.COMPLEX_TYPE_UNSUPPORTED);
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/commands/CompositeCommand.java
// Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // }
import com.healthmarketscience.jackcess.Cursor; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Map; import net.ucanaccess.jdbc.UcanaccessSQLException;
public boolean moveToNextRow(Cursor cur, Collection<String> columnNames) throws IOException { boolean hasNext = cur.moveToNextRow(); if (hasNext) { this.currentRow = cur.getCurrentRow(columnNames); } return hasNext; } public IFeedbackAction persist() throws SQLException { try { Cursor cur = indexSelector.getCursor(); cur.beforeFirst(); Collection<String> columnNames = composite.get(0).getRowPattern() .keySet(); while (composite.size() > 0 && moveToNextRow(cur, columnNames)) { Iterator<ICursorCommand> it = composite.iterator(); while (it.hasNext()) { ICursorCommand comm = it.next(); if (comm.currentRowMatches(cur, this.currentRow)) { comm.persistCurrentRow(cur); it. remove(); rollbackCache.add(comm); break; } } } return null; } catch (IOException e) {
// Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // Path: src/main/java/net/ucanaccess/commands/CompositeCommand.java import com.healthmarketscience.jackcess.Cursor; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Map; import net.ucanaccess.jdbc.UcanaccessSQLException; public boolean moveToNextRow(Cursor cur, Collection<String> columnNames) throws IOException { boolean hasNext = cur.moveToNextRow(); if (hasNext) { this.currentRow = cur.getCurrentRow(columnNames); } return hasNext; } public IFeedbackAction persist() throws SQLException { try { Cursor cur = indexSelector.getCursor(); cur.beforeFirst(); Collection<String> columnNames = composite.get(0).getRowPattern() .keySet(); while (composite.size() > 0 && moveToNextRow(cur, columnNames)) { Iterator<ICursorCommand> it = composite.iterator(); while (it.hasNext()) { ICursorCommand comm = it.next(); if (comm.currentRowMatches(cur, this.currentRow)) { comm.persistCurrentRow(cur); it. remove(); rollbackCache.add(comm); break; } } } return null; } catch (IOException e) {
throw new UcanaccessSQLException(e);
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java
// Path: src/main/java/net/ucanaccess/util/Logger.java // public class Logger { // public enum Messages{ // HSQLDB_DRIVER_NOT_FOUND, // COMPLEX_TYPE_UNSUPPORTED, // KEEP_MIRROR_AND_OTHERS // } // private static PrintWriter logPrintWriter; // private static ResourceBundle messageBundle=ResourceBundle.getBundle("net.ucanaccess.util.messages"); // // public static void dump() { // StackTraceElement[] ste = Thread.currentThread().getStackTrace(); // for (StackTraceElement el : ste) { // logPrintWriter.println(el.toString()); // logPrintWriter.flush(); // } // } // // public static void turnOffJackcessLog(){ // java.util.logging.Logger logger = java.util.logging.Logger // .getLogger("com.healthmarketscience.jackcess"); // logger.setLevel(Level.OFF); // } // // public static PrintWriter getLogPrintWriter() { // return logPrintWriter; // } // // public static String getMessage(String cod){ // return messageBundle.getString(cod); // } // // public static void log(Object obj) { // if (logPrintWriter != null){ // logPrintWriter.println(obj); // logPrintWriter.flush(); // } // } // // public static void logMessage(Messages cod){ // log( messageBundle.getString(cod.name())); // } // // public static String getLogMessage(Messages cod){ // return messageBundle.getString(cod.name()); // } // // public static void logWarning(String warning){ // System.err.println("WARNING:"+ warning); // } // public static void logWarning(Messages cod){ // logWarning( messageBundle.getString(cod.name())); // } // // public static void setLogPrintWriter(PrintWriter logPrintWriter) { // Logger.logPrintWriter = logPrintWriter; // } // }
import net.ucanaccess.util.Logger; import java.sql.SQLException;
/* Copyright (c) 2012 Marco Amadei. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact Marco Amadei at amadei.mar@gmail.com. */ package net.ucanaccess.jdbc; public class UcanaccessSQLException extends SQLException { public enum ExceptionMessages{ CONCURRENT_PROCESS_ACCESS, INVALID_CREATE_STATEMENT, INVALID_INTERVAL_VALUE, INVALID_JACKCESS_OPENER, INVALID_MONTH_NUMBER, NOT_A_VALID_PASSWORD, ONLY_IN_MEMORY_ALLOWED, UNPARSABLE_DATE, COMPLEX_TYPE_UNSUPPORTED, INVALID_PARAMETER, INVALID_TYPES_IN_COMBINATION, UNSUPPORTED_TYPE } private static final long serialVersionUID = -1432048647665807662L; private Throwable cause; public UcanaccessSQLException() { } public UcanaccessSQLException(ExceptionMessages reason) {
// Path: src/main/java/net/ucanaccess/util/Logger.java // public class Logger { // public enum Messages{ // HSQLDB_DRIVER_NOT_FOUND, // COMPLEX_TYPE_UNSUPPORTED, // KEEP_MIRROR_AND_OTHERS // } // private static PrintWriter logPrintWriter; // private static ResourceBundle messageBundle=ResourceBundle.getBundle("net.ucanaccess.util.messages"); // // public static void dump() { // StackTraceElement[] ste = Thread.currentThread().getStackTrace(); // for (StackTraceElement el : ste) { // logPrintWriter.println(el.toString()); // logPrintWriter.flush(); // } // } // // public static void turnOffJackcessLog(){ // java.util.logging.Logger logger = java.util.logging.Logger // .getLogger("com.healthmarketscience.jackcess"); // logger.setLevel(Level.OFF); // } // // public static PrintWriter getLogPrintWriter() { // return logPrintWriter; // } // // public static String getMessage(String cod){ // return messageBundle.getString(cod); // } // // public static void log(Object obj) { // if (logPrintWriter != null){ // logPrintWriter.println(obj); // logPrintWriter.flush(); // } // } // // public static void logMessage(Messages cod){ // log( messageBundle.getString(cod.name())); // } // // public static String getLogMessage(Messages cod){ // return messageBundle.getString(cod.name()); // } // // public static void logWarning(String warning){ // System.err.println("WARNING:"+ warning); // } // public static void logWarning(Messages cod){ // logWarning( messageBundle.getString(cod.name())); // } // // public static void setLogPrintWriter(PrintWriter logPrintWriter) { // Logger.logPrintWriter = logPrintWriter; // } // } // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java import net.ucanaccess.util.Logger; import java.sql.SQLException; /* Copyright (c) 2012 Marco Amadei. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact Marco Amadei at amadei.mar@gmail.com. */ package net.ucanaccess.jdbc; public class UcanaccessSQLException extends SQLException { public enum ExceptionMessages{ CONCURRENT_PROCESS_ACCESS, INVALID_CREATE_STATEMENT, INVALID_INTERVAL_VALUE, INVALID_JACKCESS_OPENER, INVALID_MONTH_NUMBER, NOT_A_VALID_PASSWORD, ONLY_IN_MEMORY_ALLOWED, UNPARSABLE_DATE, COMPLEX_TYPE_UNSUPPORTED, INVALID_PARAMETER, INVALID_TYPES_IN_COMBINATION, UNSUPPORTED_TYPE } private static final long serialVersionUID = -1432048647665807662L; private Throwable cause; public UcanaccessSQLException() { } public UcanaccessSQLException(ExceptionMessages reason) {
super(Logger.getMessage(reason.name()));
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/ext/FunctionType.java
// Path: src/main/java/net/ucanaccess/converters/TypesMap.java // public static enum AccessType{ // BYTE, // COUNTER, // CURRENCY, // DATETIME, // DOUBLE, // GUID, // INTEGER, // LONG, // MEMO, // NUMERIC, // OLE, // SINGLE, // TEXT, // YESNO // }
import java.lang.annotation.*; import net.ucanaccess.converters.TypesMap.AccessType;
package net.ucanaccess.ext; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface FunctionType {
// Path: src/main/java/net/ucanaccess/converters/TypesMap.java // public static enum AccessType{ // BYTE, // COUNTER, // CURRENCY, // DATETIME, // DOUBLE, // GUID, // INTEGER, // LONG, // MEMO, // NUMERIC, // OLE, // SINGLE, // TEXT, // YESNO // } // Path: src/main/java/net/ucanaccess/ext/FunctionType.java import java.lang.annotation.*; import net.ucanaccess.converters.TypesMap.AccessType; package net.ucanaccess.ext; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface FunctionType {
AccessType[] argumentTypes() ;
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/console/Main.java
// Path: src/main/java/net/ucanaccess/util/Logger.java // public class Logger { // public enum Messages{ // HSQLDB_DRIVER_NOT_FOUND, // COMPLEX_TYPE_UNSUPPORTED, // KEEP_MIRROR_AND_OTHERS // } // private static PrintWriter logPrintWriter; // private static ResourceBundle messageBundle=ResourceBundle.getBundle("net.ucanaccess.util.messages"); // // public static void dump() { // StackTraceElement[] ste = Thread.currentThread().getStackTrace(); // for (StackTraceElement el : ste) { // logPrintWriter.println(el.toString()); // logPrintWriter.flush(); // } // } // // public static void turnOffJackcessLog(){ // java.util.logging.Logger logger = java.util.logging.Logger // .getLogger("com.healthmarketscience.jackcess"); // logger.setLevel(Level.OFF); // } // // public static PrintWriter getLogPrintWriter() { // return logPrintWriter; // } // // public static String getMessage(String cod){ // return messageBundle.getString(cod); // } // // public static void log(Object obj) { // if (logPrintWriter != null){ // logPrintWriter.println(obj); // logPrintWriter.flush(); // } // } // // public static void logMessage(Messages cod){ // log( messageBundle.getString(cod.name())); // } // // public static String getLogMessage(Messages cod){ // return messageBundle.getString(cod.name()); // } // // public static void logWarning(String warning){ // System.err.println("WARNING:"+ warning); // } // public static void logWarning(Messages cod){ // logWarning( messageBundle.getString(cod.name())); // } // // public static void setLogPrintWriter(PrintWriter logPrintWriter) { // Logger.logPrintWriter = logPrintWriter; // } // }
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.math.BigDecimal; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Statement; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Properties; import java.util.StringTokenizer; import java.util.Map.Entry; import net.ucanaccess.util.Logger; import com.healthmarketscience.jackcess.Database; import com.healthmarketscience.jackcess.DatabaseBuilder;
try{ db = DatabaseBuilder.open(fl); }catch(IOException e){ DatabaseBuilder dbb=new DatabaseBuilder(); dbb.setReadOnly(true); db= dbb.open(); } String pwd = db.getDatabasePassword(); db.close(); return pwd != null; } private static void lcProperties(Properties pr) { Properties nb=new Properties(); for( Entry<Object, Object> entry:pr.entrySet()){ String key=(String)entry.getKey(); if(key!=null){ nb.put(key.toLowerCase(), entry.getValue()); } } pr.clear(); pr.putAll(nb); } /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception {
// Path: src/main/java/net/ucanaccess/util/Logger.java // public class Logger { // public enum Messages{ // HSQLDB_DRIVER_NOT_FOUND, // COMPLEX_TYPE_UNSUPPORTED, // KEEP_MIRROR_AND_OTHERS // } // private static PrintWriter logPrintWriter; // private static ResourceBundle messageBundle=ResourceBundle.getBundle("net.ucanaccess.util.messages"); // // public static void dump() { // StackTraceElement[] ste = Thread.currentThread().getStackTrace(); // for (StackTraceElement el : ste) { // logPrintWriter.println(el.toString()); // logPrintWriter.flush(); // } // } // // public static void turnOffJackcessLog(){ // java.util.logging.Logger logger = java.util.logging.Logger // .getLogger("com.healthmarketscience.jackcess"); // logger.setLevel(Level.OFF); // } // // public static PrintWriter getLogPrintWriter() { // return logPrintWriter; // } // // public static String getMessage(String cod){ // return messageBundle.getString(cod); // } // // public static void log(Object obj) { // if (logPrintWriter != null){ // logPrintWriter.println(obj); // logPrintWriter.flush(); // } // } // // public static void logMessage(Messages cod){ // log( messageBundle.getString(cod.name())); // } // // public static String getLogMessage(Messages cod){ // return messageBundle.getString(cod.name()); // } // // public static void logWarning(String warning){ // System.err.println("WARNING:"+ warning); // } // public static void logWarning(Messages cod){ // logWarning( messageBundle.getString(cod.name())); // } // // public static void setLogPrintWriter(PrintWriter logPrintWriter) { // Logger.logPrintWriter = logPrintWriter; // } // } // Path: src/main/java/net/ucanaccess/console/Main.java import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.math.BigDecimal; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Statement; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Properties; import java.util.StringTokenizer; import java.util.Map.Entry; import net.ucanaccess.util.Logger; import com.healthmarketscience.jackcess.Database; import com.healthmarketscience.jackcess.DatabaseBuilder; try{ db = DatabaseBuilder.open(fl); }catch(IOException e){ DatabaseBuilder dbb=new DatabaseBuilder(); dbb.setReadOnly(true); db= dbb.open(); } String pwd = db.getDatabasePassword(); db.close(); return pwd != null; } private static void lcProperties(Properties pr) { Properties nb=new Properties(); for( Entry<Object, Object> entry:pr.entrySet()){ String key=(String)entry.getKey(); if(key!=null){ nb.put(key.toLowerCase(), entry.getValue()); } } pr.clear(); pr.putAll(nb); } /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception {
Logger.setLogPrintWriter(new PrintWriter(System.out));
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/jdbc/FeatureNotSupportedException.java
// Path: src/main/java/net/ucanaccess/util/Logger.java // public class Logger { // public enum Messages{ // HSQLDB_DRIVER_NOT_FOUND, // COMPLEX_TYPE_UNSUPPORTED, // KEEP_MIRROR_AND_OTHERS // } // private static PrintWriter logPrintWriter; // private static ResourceBundle messageBundle=ResourceBundle.getBundle("net.ucanaccess.util.messages"); // // public static void dump() { // StackTraceElement[] ste = Thread.currentThread().getStackTrace(); // for (StackTraceElement el : ste) { // logPrintWriter.println(el.toString()); // logPrintWriter.flush(); // } // } // // public static void turnOffJackcessLog(){ // java.util.logging.Logger logger = java.util.logging.Logger // .getLogger("com.healthmarketscience.jackcess"); // logger.setLevel(Level.OFF); // } // // public static PrintWriter getLogPrintWriter() { // return logPrintWriter; // } // // public static String getMessage(String cod){ // return messageBundle.getString(cod); // } // // public static void log(Object obj) { // if (logPrintWriter != null){ // logPrintWriter.println(obj); // logPrintWriter.flush(); // } // } // // public static void logMessage(Messages cod){ // log( messageBundle.getString(cod.name())); // } // // public static String getLogMessage(Messages cod){ // return messageBundle.getString(cod.name()); // } // // public static void logWarning(String warning){ // System.err.println("WARNING:"+ warning); // } // public static void logWarning(Messages cod){ // logWarning( messageBundle.getString(cod.name())); // } // // public static void setLogPrintWriter(PrintWriter logPrintWriter) { // Logger.logPrintWriter = logPrintWriter; // } // }
import net.ucanaccess.util.Logger;
/* Copyright (c) 2012 Marco Amadei. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact Marco Amadei at amadei.mar@gmail.com. */ package net.ucanaccess.jdbc; public class FeatureNotSupportedException extends java.sql.SQLFeatureNotSupportedException { public enum NotSupportedMessage{ NOT_SUPPORTED, NOT_SUPPORTED_YET } private static final long serialVersionUID = -6457220326288384415L; public FeatureNotSupportedException() { this(NotSupportedMessage.NOT_SUPPORTED); } public FeatureNotSupportedException(NotSupportedMessage message) {
// Path: src/main/java/net/ucanaccess/util/Logger.java // public class Logger { // public enum Messages{ // HSQLDB_DRIVER_NOT_FOUND, // COMPLEX_TYPE_UNSUPPORTED, // KEEP_MIRROR_AND_OTHERS // } // private static PrintWriter logPrintWriter; // private static ResourceBundle messageBundle=ResourceBundle.getBundle("net.ucanaccess.util.messages"); // // public static void dump() { // StackTraceElement[] ste = Thread.currentThread().getStackTrace(); // for (StackTraceElement el : ste) { // logPrintWriter.println(el.toString()); // logPrintWriter.flush(); // } // } // // public static void turnOffJackcessLog(){ // java.util.logging.Logger logger = java.util.logging.Logger // .getLogger("com.healthmarketscience.jackcess"); // logger.setLevel(Level.OFF); // } // // public static PrintWriter getLogPrintWriter() { // return logPrintWriter; // } // // public static String getMessage(String cod){ // return messageBundle.getString(cod); // } // // public static void log(Object obj) { // if (logPrintWriter != null){ // logPrintWriter.println(obj); // logPrintWriter.flush(); // } // } // // public static void logMessage(Messages cod){ // log( messageBundle.getString(cod.name())); // } // // public static String getLogMessage(Messages cod){ // return messageBundle.getString(cod.name()); // } // // public static void logWarning(String warning){ // System.err.println("WARNING:"+ warning); // } // public static void logWarning(Messages cod){ // logWarning( messageBundle.getString(cod.name())); // } // // public static void setLogPrintWriter(PrintWriter logPrintWriter) { // Logger.logPrintWriter = logPrintWriter; // } // } // Path: src/main/java/net/ucanaccess/jdbc/FeatureNotSupportedException.java import net.ucanaccess.util.Logger; /* Copyright (c) 2012 Marco Amadei. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact Marco Amadei at amadei.mar@gmail.com. */ package net.ucanaccess.jdbc; public class FeatureNotSupportedException extends java.sql.SQLFeatureNotSupportedException { public enum NotSupportedMessage{ NOT_SUPPORTED, NOT_SUPPORTED_YET } private static final long serialVersionUID = -6457220326288384415L; public FeatureNotSupportedException() { this(NotSupportedMessage.NOT_SUPPORTED); } public FeatureNotSupportedException(NotSupportedMessage message) {
super(Logger.getMessage(message.name()));
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/jdbc/UcanaccessDataSource.java
// Path: src/main/java/net/ucanaccess/util/Logger.java // public class Logger { // public enum Messages{ // HSQLDB_DRIVER_NOT_FOUND, // COMPLEX_TYPE_UNSUPPORTED, // KEEP_MIRROR_AND_OTHERS // } // private static PrintWriter logPrintWriter; // private static ResourceBundle messageBundle=ResourceBundle.getBundle("net.ucanaccess.util.messages"); // // public static void dump() { // StackTraceElement[] ste = Thread.currentThread().getStackTrace(); // for (StackTraceElement el : ste) { // logPrintWriter.println(el.toString()); // logPrintWriter.flush(); // } // } // // public static void turnOffJackcessLog(){ // java.util.logging.Logger logger = java.util.logging.Logger // .getLogger("com.healthmarketscience.jackcess"); // logger.setLevel(Level.OFF); // } // // public static PrintWriter getLogPrintWriter() { // return logPrintWriter; // } // // public static String getMessage(String cod){ // return messageBundle.getString(cod); // } // // public static void log(Object obj) { // if (logPrintWriter != null){ // logPrintWriter.println(obj); // logPrintWriter.flush(); // } // } // // public static void logMessage(Messages cod){ // log( messageBundle.getString(cod.name())); // } // // public static String getLogMessage(Messages cod){ // return messageBundle.getString(cod.name()); // } // // public static void logWarning(String warning){ // System.err.println("WARNING:"+ warning); // } // public static void logWarning(Messages cod){ // logWarning( messageBundle.getString(cod.name())); // } // // public static void setLogPrintWriter(PrintWriter logPrintWriter) { // Logger.logPrintWriter = logPrintWriter; // } // }
import javax.naming.Referenceable; import javax.naming.StringRefAddr; import javax.sql.DataSource; import net.ucanaccess.util.Logger; import java.io.PrintWriter; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import javax.naming.NamingException; import javax.naming.Reference;
/* Copyright (c) 2012 Marco Amadei. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact Marco Amadei at amadei.mar@gmail.com. */ package net.ucanaccess.jdbc; public class UcanaccessDataSource implements Serializable, Referenceable, DataSource { /** * */ private static final long serialVersionUID = 8574198937631043152L; private String accessPath ; private int loginTimeout = 0;
// Path: src/main/java/net/ucanaccess/util/Logger.java // public class Logger { // public enum Messages{ // HSQLDB_DRIVER_NOT_FOUND, // COMPLEX_TYPE_UNSUPPORTED, // KEEP_MIRROR_AND_OTHERS // } // private static PrintWriter logPrintWriter; // private static ResourceBundle messageBundle=ResourceBundle.getBundle("net.ucanaccess.util.messages"); // // public static void dump() { // StackTraceElement[] ste = Thread.currentThread().getStackTrace(); // for (StackTraceElement el : ste) { // logPrintWriter.println(el.toString()); // logPrintWriter.flush(); // } // } // // public static void turnOffJackcessLog(){ // java.util.logging.Logger logger = java.util.logging.Logger // .getLogger("com.healthmarketscience.jackcess"); // logger.setLevel(Level.OFF); // } // // public static PrintWriter getLogPrintWriter() { // return logPrintWriter; // } // // public static String getMessage(String cod){ // return messageBundle.getString(cod); // } // // public static void log(Object obj) { // if (logPrintWriter != null){ // logPrintWriter.println(obj); // logPrintWriter.flush(); // } // } // // public static void logMessage(Messages cod){ // log( messageBundle.getString(cod.name())); // } // // public static String getLogMessage(Messages cod){ // return messageBundle.getString(cod.name()); // } // // public static void logWarning(String warning){ // System.err.println("WARNING:"+ warning); // } // public static void logWarning(Messages cod){ // logWarning( messageBundle.getString(cod.name())); // } // // public static void setLogPrintWriter(PrintWriter logPrintWriter) { // Logger.logPrintWriter = logPrintWriter; // } // } // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessDataSource.java import javax.naming.Referenceable; import javax.naming.StringRefAddr; import javax.sql.DataSource; import net.ucanaccess.util.Logger; import java.io.PrintWriter; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import javax.naming.NamingException; import javax.naming.Reference; /* Copyright (c) 2012 Marco Amadei. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact Marco Amadei at amadei.mar@gmail.com. */ package net.ucanaccess.jdbc; public class UcanaccessDataSource implements Serializable, Referenceable, DataSource { /** * */ private static final long serialVersionUID = 8574198937631043152L; private String accessPath ; private int loginTimeout = 0;
private transient PrintWriter logWriter = Logger.getLogPrintWriter();
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/converters/Functions.java
// Path: src/main/java/net/ucanaccess/converters/TypesMap.java // public static enum AccessType{ // BYTE, // COUNTER, // CURRENCY, // DATETIME, // DOUBLE, // GUID, // INTEGER, // LONG, // MEMO, // NUMERIC, // OLE, // SINGLE, // TEXT, // YESNO // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // }
import java.util.Calendar; import java.util.Date; import java.util.Locale; import net.ucanaccess.converters.TypesMap.AccessType; import net.ucanaccess.ext.FunctionType; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; import java.text.DateFormatSymbols; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat;
/* Copyright (c) 2012 Marco Amadei. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact Marco Amadei at amadei.mar@gmail.com. */ package net.ucanaccess.converters; public class Functions { private static Double rnd; private static Double lastRnd; public final static SimpleDateFormat[] SDFA = new SimpleDateFormat[] { new SimpleDateFormat("MMM dd,yyyy"), new SimpleDateFormat("MM dd,yyyy"), new SimpleDateFormat("MM/dd/yyyy"), new SimpleDateFormat("MMM dd hh:mm:ss"), new SimpleDateFormat("MM dd hh:mm:ss"), new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"), new SimpleDateFormat("yyyy-MM-dd"), new SimpleDateFormat("MM/dd/yyyy hh:mm:ss") }; public static final SimpleDateFormat SDFBB = new SimpleDateFormat( "yyyy-MM-dd");
// Path: src/main/java/net/ucanaccess/converters/TypesMap.java // public static enum AccessType{ // BYTE, // COUNTER, // CURRENCY, // DATETIME, // DOUBLE, // GUID, // INTEGER, // LONG, // MEMO, // NUMERIC, // OLE, // SINGLE, // TEXT, // YESNO // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // Path: src/main/java/net/ucanaccess/converters/Functions.java import java.util.Calendar; import java.util.Date; import java.util.Locale; import net.ucanaccess.converters.TypesMap.AccessType; import net.ucanaccess.ext.FunctionType; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; import java.text.DateFormatSymbols; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat; /* Copyright (c) 2012 Marco Amadei. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You can contact Marco Amadei at amadei.mar@gmail.com. */ package net.ucanaccess.converters; public class Functions { private static Double rnd; private static Double lastRnd; public final static SimpleDateFormat[] SDFA = new SimpleDateFormat[] { new SimpleDateFormat("MMM dd,yyyy"), new SimpleDateFormat("MM dd,yyyy"), new SimpleDateFormat("MM/dd/yyyy"), new SimpleDateFormat("MMM dd hh:mm:ss"), new SimpleDateFormat("MM dd hh:mm:ss"), new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"), new SimpleDateFormat("yyyy-MM-dd"), new SimpleDateFormat("MM/dd/yyyy hh:mm:ss") }; public static final SimpleDateFormat SDFBB = new SimpleDateFormat( "yyyy-MM-dd");
@FunctionType(functionName = "ASC", argumentTypes = { AccessType.MEMO }, returnType = AccessType.LONG)
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/converters/Functions.java
// Path: src/main/java/net/ucanaccess/converters/TypesMap.java // public static enum AccessType{ // BYTE, // COUNTER, // CURRENCY, // DATETIME, // DOUBLE, // GUID, // INTEGER, // LONG, // MEMO, // NUMERIC, // OLE, // SINGLE, // TEXT, // YESNO // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // }
import java.util.Calendar; import java.util.Date; import java.util.Locale; import net.ucanaccess.converters.TypesMap.AccessType; import net.ucanaccess.ext.FunctionType; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; import java.text.DateFormatSymbols; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat;
@FunctionType(functionName = "ATN", argumentTypes = { AccessType.DOUBLE }, returnType = AccessType.DOUBLE) public static double atn(double v) { return Math.atan(v); } @FunctionType(functionName = "CBOOL", argumentTypes = { AccessType.NUMERIC }, returnType = AccessType.YESNO) public static boolean cbool(BigDecimal value) { return cbool((Object) value); } @FunctionType(functionName = "CBOOL", argumentTypes = { AccessType.YESNO }, returnType = AccessType.YESNO) public static boolean cbool(Boolean value) { return cbool((Object) value); } private static boolean cbool(Object obj) { boolean r = (obj instanceof Boolean) ? (Boolean) obj : (obj instanceof String) ? Boolean.valueOf((String) obj) : (obj instanceof Number) ? ((Number) obj) .doubleValue() != 0 : false; return r; } @FunctionType(functionName = "CBOOL", argumentTypes = { AccessType.MEMO }, returnType = AccessType.YESNO) public static boolean cbool(String value) { return cbool((Object) value); } @FunctionType(functionName = "CCUR", argumentTypes = { AccessType.CURRENCY }, returnType = AccessType.CURRENCY) public static BigDecimal ccur(BigDecimal value)
// Path: src/main/java/net/ucanaccess/converters/TypesMap.java // public static enum AccessType{ // BYTE, // COUNTER, // CURRENCY, // DATETIME, // DOUBLE, // GUID, // INTEGER, // LONG, // MEMO, // NUMERIC, // OLE, // SINGLE, // TEXT, // YESNO // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // Path: src/main/java/net/ucanaccess/converters/Functions.java import java.util.Calendar; import java.util.Date; import java.util.Locale; import net.ucanaccess.converters.TypesMap.AccessType; import net.ucanaccess.ext.FunctionType; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; import java.text.DateFormatSymbols; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat; @FunctionType(functionName = "ATN", argumentTypes = { AccessType.DOUBLE }, returnType = AccessType.DOUBLE) public static double atn(double v) { return Math.atan(v); } @FunctionType(functionName = "CBOOL", argumentTypes = { AccessType.NUMERIC }, returnType = AccessType.YESNO) public static boolean cbool(BigDecimal value) { return cbool((Object) value); } @FunctionType(functionName = "CBOOL", argumentTypes = { AccessType.YESNO }, returnType = AccessType.YESNO) public static boolean cbool(Boolean value) { return cbool((Object) value); } private static boolean cbool(Object obj) { boolean r = (obj instanceof Boolean) ? (Boolean) obj : (obj instanceof String) ? Boolean.valueOf((String) obj) : (obj instanceof Number) ? ((Number) obj) .doubleValue() != 0 : false; return r; } @FunctionType(functionName = "CBOOL", argumentTypes = { AccessType.MEMO }, returnType = AccessType.YESNO) public static boolean cbool(String value) { return cbool((Object) value); } @FunctionType(functionName = "CCUR", argumentTypes = { AccessType.CURRENCY }, returnType = AccessType.CURRENCY) public static BigDecimal ccur(BigDecimal value)
throws UcanaccessSQLException {
andrew-nguyen/ucanaccess
src/main/java/net/ucanaccess/converters/Functions.java
// Path: src/main/java/net/ucanaccess/converters/TypesMap.java // public static enum AccessType{ // BYTE, // COUNTER, // CURRENCY, // DATETIME, // DOUBLE, // GUID, // INTEGER, // LONG, // MEMO, // NUMERIC, // OLE, // SINGLE, // TEXT, // YESNO // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // }
import java.util.Calendar; import java.util.Date; import java.util.Locale; import net.ucanaccess.converters.TypesMap.AccessType; import net.ucanaccess.ext.FunctionType; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; import java.text.DateFormatSymbols; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat;
} @FunctionType(namingConflict = true, functionName = "DATEADD", argumentTypes = { AccessType.MEMO, AccessType.LONG, AccessType.DATETIME }, returnType = AccessType.DATETIME) public static Date dateAdd(String intv, int vl, Date dt) throws UcanaccessSQLException { if (dt == null || intv == null) return null; Calendar cl = Calendar.getInstance(); cl.setTime(dt); if (intv.equalsIgnoreCase("yyyy")) { cl.add(Calendar.YEAR, vl); } else if (intv.equalsIgnoreCase("q")) { cl.add(Calendar.MONTH, vl * 3); } else if (intv.equalsIgnoreCase("y") || intv.equalsIgnoreCase("d")) { cl.add(Calendar.DAY_OF_YEAR, vl); } else if (intv.equalsIgnoreCase("m")) { cl.add(Calendar.MONTH, vl); } else if (intv.equalsIgnoreCase("w")) { cl.add(Calendar.DAY_OF_WEEK, vl); } else if (intv.equalsIgnoreCase("ww")) { cl.add(Calendar.WEEK_OF_YEAR, vl); } else if (intv.equalsIgnoreCase("h")) { cl.add(Calendar.HOUR, vl); } else if (intv.equalsIgnoreCase("n")) { cl.add(Calendar.MINUTE, vl); } else if (intv.equalsIgnoreCase("s")) { cl.add(Calendar.SECOND, vl); } else throw new UcanaccessSQLException(
// Path: src/main/java/net/ucanaccess/converters/TypesMap.java // public static enum AccessType{ // BYTE, // COUNTER, // CURRENCY, // DATETIME, // DOUBLE, // GUID, // INTEGER, // LONG, // MEMO, // NUMERIC, // OLE, // SINGLE, // TEXT, // YESNO // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public class UcanaccessSQLException extends SQLException { // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // private static final long serialVersionUID = -1432048647665807662L; // private Throwable cause; // public UcanaccessSQLException() { // } // // public UcanaccessSQLException(ExceptionMessages reason) { // super(Logger.getMessage(reason.name())); // } // // public UcanaccessSQLException(String reason, String SQLState) { // super(Logger.getMessage(reason), SQLState); // } // // public UcanaccessSQLException(String reason, String SQLState, int vendorCode) { // super(Logger.getMessage(reason), SQLState, vendorCode); // } // // public UcanaccessSQLException(String reason, String sqlState, // int vendorCode, Throwable cause) { // super(Logger.getMessage(reason), sqlState, vendorCode, cause); // } // // public UcanaccessSQLException(String reason, String sqlState, Throwable cause) { // super(Logger.getMessage(reason), sqlState, cause); // } // // public UcanaccessSQLException(String reason, Throwable cause) { // super(Logger.getMessage(reason), cause); // } // // public UcanaccessSQLException(Throwable cause) { // super( explaneCause(cause)); // this.cause=cause; // } // // public static String explaneCause(Throwable cause){ // if(cause instanceof SQLException){ // SQLException se=(SQLException)cause; // if(se.getErrorCode()==-5562){ // return cause.getMessage()+" "+Logger.getMessage(ExceptionMessages.INVALID_TYPES_IN_COMBINATION.name()); // } // } // return cause.getMessage(); // } // // public Throwable getCause() { // return this.cause; // } // } // // Path: src/main/java/net/ucanaccess/jdbc/UcanaccessSQLException.java // public enum ExceptionMessages{ // CONCURRENT_PROCESS_ACCESS, // INVALID_CREATE_STATEMENT, // INVALID_INTERVAL_VALUE, // INVALID_JACKCESS_OPENER, // INVALID_MONTH_NUMBER, // NOT_A_VALID_PASSWORD, // ONLY_IN_MEMORY_ALLOWED, // UNPARSABLE_DATE, // COMPLEX_TYPE_UNSUPPORTED, // INVALID_PARAMETER, // INVALID_TYPES_IN_COMBINATION, // UNSUPPORTED_TYPE // } // Path: src/main/java/net/ucanaccess/converters/Functions.java import java.util.Calendar; import java.util.Date; import java.util.Locale; import net.ucanaccess.converters.TypesMap.AccessType; import net.ucanaccess.ext.FunctionType; import net.ucanaccess.jdbc.UcanaccessSQLException; import net.ucanaccess.jdbc.UcanaccessSQLException.ExceptionMessages; import java.math.BigDecimal; import java.math.MathContext; import java.sql.Timestamp; import java.text.DateFormatSymbols; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat; } @FunctionType(namingConflict = true, functionName = "DATEADD", argumentTypes = { AccessType.MEMO, AccessType.LONG, AccessType.DATETIME }, returnType = AccessType.DATETIME) public static Date dateAdd(String intv, int vl, Date dt) throws UcanaccessSQLException { if (dt == null || intv == null) return null; Calendar cl = Calendar.getInstance(); cl.setTime(dt); if (intv.equalsIgnoreCase("yyyy")) { cl.add(Calendar.YEAR, vl); } else if (intv.equalsIgnoreCase("q")) { cl.add(Calendar.MONTH, vl * 3); } else if (intv.equalsIgnoreCase("y") || intv.equalsIgnoreCase("d")) { cl.add(Calendar.DAY_OF_YEAR, vl); } else if (intv.equalsIgnoreCase("m")) { cl.add(Calendar.MONTH, vl); } else if (intv.equalsIgnoreCase("w")) { cl.add(Calendar.DAY_OF_WEEK, vl); } else if (intv.equalsIgnoreCase("ww")) { cl.add(Calendar.WEEK_OF_YEAR, vl); } else if (intv.equalsIgnoreCase("h")) { cl.add(Calendar.HOUR, vl); } else if (intv.equalsIgnoreCase("n")) { cl.add(Calendar.MINUTE, vl); } else if (intv.equalsIgnoreCase("s")) { cl.add(Calendar.SECOND, vl); } else throw new UcanaccessSQLException(
ExceptionMessages.INVALID_INTERVAL_VALUE);
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/config/ThriftClientConfig.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/Constants.java // public class Constants { // // public static final String ZK_PATH_PREFIX = "/ourea"; // // public static final String PATH_SEPARATOR = "/"; // // public static final String GROUP_KEY = "group"; // // public static final String VERSION_KEY = "version"; // // public static final String INTERFACE_KEY = "interface"; // // public static final String INVOKER_KEY = "invoker"; // // public static final String DEFAULT_INVOKER_PROVIDER = "provider"; // // public static final String DEFAULT_INVOKER_CONSUMER = "consumer"; // // public static final String DEFAULT_GROUP_NAME = "ourea"; // // public static final String DEFAULT_VERSION_VALUE = "1.0.0"; // // public static final int DEFAULT_WEIGHT_VALUE = 0; // // public static final int DEFAULT_TIMEOUT_VALUE = 1000; // // public static final int DEFAULT_THRIFT_PORT = 1000; // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/ILoadBalanceStrategy.java // public interface ILoadBalanceStrategy { // // /** // * 从众多连接池子中选择其中一个池子. // * // * @param invokeConns // * @return // */ // public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation); // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java // public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy { // // private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>(); // // @Override // protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) { // // String key = invocation.getInterfaceName() + invocation.getMethodName(); // Integer cur = current.get(key); // // if (cur == null || cur >= Integer.MAX_VALUE - 1) { // cur = 0; // } // current.putIfAbsent(key, cur + 1); // // try { // return invokeConns.get(cur % invokeConns.size()); // }catch (IndexOutOfBoundsException e){ // return invokeConns.get(0); // } // // } // }
import com.taocoder.ourea.core.common.Constants; import com.taocoder.ourea.core.loadbalance.ILoadBalanceStrategy; import com.taocoder.ourea.core.loadbalance.RoundRobinLoadBalanceStrategy;
/* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.config; /** * thrift client 相关配置 * * @author tao.ke Date: 16/4/28 Time: 上午10:54 */ public class ThriftClientConfig { /** * 服务组,不同组之间不能服务交互 */ private String group = Constants.DEFAULT_GROUP_NAME; /** * 服务版本,不同版本之间不能交互 */ private String version = Constants.DEFAULT_VERSION_VALUE; /** * 超时时间 */ private int timeout = Constants.DEFAULT_TIMEOUT_VALUE; /** * 服务重试次数,默认重试一次 */ private int retryTimes = 1; /** * 服务client的负载策略 */
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/Constants.java // public class Constants { // // public static final String ZK_PATH_PREFIX = "/ourea"; // // public static final String PATH_SEPARATOR = "/"; // // public static final String GROUP_KEY = "group"; // // public static final String VERSION_KEY = "version"; // // public static final String INTERFACE_KEY = "interface"; // // public static final String INVOKER_KEY = "invoker"; // // public static final String DEFAULT_INVOKER_PROVIDER = "provider"; // // public static final String DEFAULT_INVOKER_CONSUMER = "consumer"; // // public static final String DEFAULT_GROUP_NAME = "ourea"; // // public static final String DEFAULT_VERSION_VALUE = "1.0.0"; // // public static final int DEFAULT_WEIGHT_VALUE = 0; // // public static final int DEFAULT_TIMEOUT_VALUE = 1000; // // public static final int DEFAULT_THRIFT_PORT = 1000; // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/ILoadBalanceStrategy.java // public interface ILoadBalanceStrategy { // // /** // * 从众多连接池子中选择其中一个池子. // * // * @param invokeConns // * @return // */ // public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation); // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java // public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy { // // private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>(); // // @Override // protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) { // // String key = invocation.getInterfaceName() + invocation.getMethodName(); // Integer cur = current.get(key); // // if (cur == null || cur >= Integer.MAX_VALUE - 1) { // cur = 0; // } // current.putIfAbsent(key, cur + 1); // // try { // return invokeConns.get(cur % invokeConns.size()); // }catch (IndexOutOfBoundsException e){ // return invokeConns.get(0); // } // // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ThriftClientConfig.java import com.taocoder.ourea.core.common.Constants; import com.taocoder.ourea.core.loadbalance.ILoadBalanceStrategy; import com.taocoder.ourea.core.loadbalance.RoundRobinLoadBalanceStrategy; /* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.config; /** * thrift client 相关配置 * * @author tao.ke Date: 16/4/28 Time: 上午10:54 */ public class ThriftClientConfig { /** * 服务组,不同组之间不能服务交互 */ private String group = Constants.DEFAULT_GROUP_NAME; /** * 服务版本,不同版本之间不能交互 */ private String version = Constants.DEFAULT_VERSION_VALUE; /** * 超时时间 */ private int timeout = Constants.DEFAULT_TIMEOUT_VALUE; /** * 服务重试次数,默认重试一次 */ private int retryTimes = 1; /** * 服务client的负载策略 */
private ILoadBalanceStrategy loadBalanceStrategy = new RoundRobinLoadBalanceStrategy();
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/config/ThriftClientConfig.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/Constants.java // public class Constants { // // public static final String ZK_PATH_PREFIX = "/ourea"; // // public static final String PATH_SEPARATOR = "/"; // // public static final String GROUP_KEY = "group"; // // public static final String VERSION_KEY = "version"; // // public static final String INTERFACE_KEY = "interface"; // // public static final String INVOKER_KEY = "invoker"; // // public static final String DEFAULT_INVOKER_PROVIDER = "provider"; // // public static final String DEFAULT_INVOKER_CONSUMER = "consumer"; // // public static final String DEFAULT_GROUP_NAME = "ourea"; // // public static final String DEFAULT_VERSION_VALUE = "1.0.0"; // // public static final int DEFAULT_WEIGHT_VALUE = 0; // // public static final int DEFAULT_TIMEOUT_VALUE = 1000; // // public static final int DEFAULT_THRIFT_PORT = 1000; // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/ILoadBalanceStrategy.java // public interface ILoadBalanceStrategy { // // /** // * 从众多连接池子中选择其中一个池子. // * // * @param invokeConns // * @return // */ // public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation); // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java // public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy { // // private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>(); // // @Override // protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) { // // String key = invocation.getInterfaceName() + invocation.getMethodName(); // Integer cur = current.get(key); // // if (cur == null || cur >= Integer.MAX_VALUE - 1) { // cur = 0; // } // current.putIfAbsent(key, cur + 1); // // try { // return invokeConns.get(cur % invokeConns.size()); // }catch (IndexOutOfBoundsException e){ // return invokeConns.get(0); // } // // } // }
import com.taocoder.ourea.core.common.Constants; import com.taocoder.ourea.core.loadbalance.ILoadBalanceStrategy; import com.taocoder.ourea.core.loadbalance.RoundRobinLoadBalanceStrategy;
/* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.config; /** * thrift client 相关配置 * * @author tao.ke Date: 16/4/28 Time: 上午10:54 */ public class ThriftClientConfig { /** * 服务组,不同组之间不能服务交互 */ private String group = Constants.DEFAULT_GROUP_NAME; /** * 服务版本,不同版本之间不能交互 */ private String version = Constants.DEFAULT_VERSION_VALUE; /** * 超时时间 */ private int timeout = Constants.DEFAULT_TIMEOUT_VALUE; /** * 服务重试次数,默认重试一次 */ private int retryTimes = 1; /** * 服务client的负载策略 */
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/Constants.java // public class Constants { // // public static final String ZK_PATH_PREFIX = "/ourea"; // // public static final String PATH_SEPARATOR = "/"; // // public static final String GROUP_KEY = "group"; // // public static final String VERSION_KEY = "version"; // // public static final String INTERFACE_KEY = "interface"; // // public static final String INVOKER_KEY = "invoker"; // // public static final String DEFAULT_INVOKER_PROVIDER = "provider"; // // public static final String DEFAULT_INVOKER_CONSUMER = "consumer"; // // public static final String DEFAULT_GROUP_NAME = "ourea"; // // public static final String DEFAULT_VERSION_VALUE = "1.0.0"; // // public static final int DEFAULT_WEIGHT_VALUE = 0; // // public static final int DEFAULT_TIMEOUT_VALUE = 1000; // // public static final int DEFAULT_THRIFT_PORT = 1000; // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/ILoadBalanceStrategy.java // public interface ILoadBalanceStrategy { // // /** // * 从众多连接池子中选择其中一个池子. // * // * @param invokeConns // * @return // */ // public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation); // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java // public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy { // // private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>(); // // @Override // protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) { // // String key = invocation.getInterfaceName() + invocation.getMethodName(); // Integer cur = current.get(key); // // if (cur == null || cur >= Integer.MAX_VALUE - 1) { // cur = 0; // } // current.putIfAbsent(key, cur + 1); // // try { // return invokeConns.get(cur % invokeConns.size()); // }catch (IndexOutOfBoundsException e){ // return invokeConns.get(0); // } // // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ThriftClientConfig.java import com.taocoder.ourea.core.common.Constants; import com.taocoder.ourea.core.loadbalance.ILoadBalanceStrategy; import com.taocoder.ourea.core.loadbalance.RoundRobinLoadBalanceStrategy; /* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.config; /** * thrift client 相关配置 * * @author tao.ke Date: 16/4/28 Time: 上午10:54 */ public class ThriftClientConfig { /** * 服务组,不同组之间不能服务交互 */ private String group = Constants.DEFAULT_GROUP_NAME; /** * 服务版本,不同版本之间不能交互 */ private String version = Constants.DEFAULT_VERSION_VALUE; /** * 超时时间 */ private int timeout = Constants.DEFAULT_TIMEOUT_VALUE; /** * 服务重试次数,默认重试一次 */ private int retryTimes = 1; /** * 服务client的负载策略 */
private ILoadBalanceStrategy loadBalanceStrategy = new RoundRobinLoadBalanceStrategy();
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RandomLoadBalanceStrategy.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // }
import java.util.List; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.lang3.RandomUtils;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:16 */ public class RandomLoadBalanceStrategy extends AbstractLoadBalanceStrategy { @Override
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RandomLoadBalanceStrategy.java import java.util.List; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.lang3.RandomUtils; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:16 */ public class RandomLoadBalanceStrategy extends AbstractLoadBalanceStrategy { @Override
protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) {
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RandomLoadBalanceStrategy.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // }
import java.util.List; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.lang3.RandomUtils;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:16 */ public class RandomLoadBalanceStrategy extends AbstractLoadBalanceStrategy { @Override
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RandomLoadBalanceStrategy.java import java.util.List; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.lang3.RandomUtils; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:16 */ public class RandomLoadBalanceStrategy extends AbstractLoadBalanceStrategy { @Override
protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) {
ketao1989/ourea
ourea-core/src/test/java/com/taocoder/ourea/ZkThriftClientSample.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/PropertiesUtils.java // public class PropertiesUtils { // // public static Properties load(String fileName) { // // InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); // return load(is); // } // // public static Properties load(InputStream is) { // // Properties properties = new Properties(); // try { // properties.load(is); // } catch (IOException e) { // e.printStackTrace(); // throw new IllegalArgumentException(e.getMessage()); // } // return properties; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ZkConfig.java // public class ZkConfig { // // /** // * zk ip:port, // */ // private String zkAddress; // // /** // * zk 超时时间 // */ // private int zkTimeout = 3000; // // /** // * 重试之间初始等待时间 // */ // private int baseSleepTimeMs = 10; // // /** // * 重试之间最长等待时间 // */ // private int maxSleepTimeMs = 1000; // // /** // * 重试次数 // */ // private int maxRetries = 3; // // public ZkConfig() { // } // // public ZkConfig(String zkAddress) { // this.zkAddress = zkAddress; // } // // public void setZkAddress(String zkAddress) { // this.zkAddress = zkAddress; // } // // public String getZkAddress() { // return zkAddress; // } // // public int getZkTimeout() { // return zkTimeout; // } // // public void setZkTimeout(int zkTimeout) { // this.zkTimeout = zkTimeout; // } // // public int getBaseSleepTimeMs() { // return baseSleepTimeMs; // } // // public void setBaseSleepTimeMs(int baseSleepTimeMs) { // this.baseSleepTimeMs = baseSleepTimeMs; // } // // public int getMaxSleepTimeMs() { // return maxSleepTimeMs; // } // // public void setMaxSleepTimeMs(int maxSleepTimeMs) { // this.maxSleepTimeMs = maxSleepTimeMs; // } // // public int getMaxRetries() { // return maxRetries; // } // // public void setMaxRetries(int maxRetries) { // this.maxRetries = maxRetries; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerProxyFactory.java // public class ConsumerProxyFactory { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerProxyFactory.class); // // /** // * 正常的业务需求,是保证全局的thrift client 单例的,因为构造client成本是很重的. 这里的,key为class_group_version // */ // private static final ConcurrentHashMap<String, Object> SERVICE_CLIENT_CONCURRENT_HASH_MAP = new ConcurrentHashMap<String, Object>(); // // private static final Joiner CLIENT_KEY_JOINER = Joiner.on("_"); // // private static final Object SERVICE_CLIENT_LOCK = new Object(); // // public <T> T getProxyClient(Class<T> clientClazz, ZkConfig zkConfig) { // return getProxyClient(clientClazz, new ThriftClientConfig(), zkConfig); // } // // @SuppressWarnings("unchecked") // public <T> T getProxyClient(Class<T> clientClazz, ThriftClientConfig config, ZkConfig zkConfig) { // // String clientKey = CLIENT_KEY_JOINER.join(clientClazz.getCanonicalName(), config.getGroup(), // config.getVersion()); // T client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // // if (client == null) { // synchronized (SERVICE_CLIENT_LOCK) { // client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // if (client == null) { // // long start = System.currentTimeMillis(); // final ServiceInfo serviceInfo = new ServiceInfo(clientClazz, config.getVersion(), // config.getGroup()); // // client = (T) Proxy.newProxyInstance(ConsumerProxyFactory.class.getClassLoader(), // new Class[] { clientClazz }, new ConsumerProxy(serviceInfo, zkConfig, config)); // SERVICE_CLIENT_CONCURRENT_HASH_MAP.putIfAbsent(clientKey, client); // LOGGER.info("build thrift client succ.cost:{},clientConfig:{},zkConfig:{}", // System.currentTimeMillis() - start, config, zkConfig); // } // } // } // return client; // } // // }
import java.util.Properties; import com.taocoder.ourea.core.common.PropertiesUtils; import com.taocoder.ourea.core.config.ZkConfig; import com.taocoder.ourea.core.consumer.ConsumerProxyFactory;
/* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea; /** * @author tao.ke Date: 16/4/27 Time: 下午5:03 */ public class ZkThriftClientSample { public static void main(String[] args) throws Exception {
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/PropertiesUtils.java // public class PropertiesUtils { // // public static Properties load(String fileName) { // // InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); // return load(is); // } // // public static Properties load(InputStream is) { // // Properties properties = new Properties(); // try { // properties.load(is); // } catch (IOException e) { // e.printStackTrace(); // throw new IllegalArgumentException(e.getMessage()); // } // return properties; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ZkConfig.java // public class ZkConfig { // // /** // * zk ip:port, // */ // private String zkAddress; // // /** // * zk 超时时间 // */ // private int zkTimeout = 3000; // // /** // * 重试之间初始等待时间 // */ // private int baseSleepTimeMs = 10; // // /** // * 重试之间最长等待时间 // */ // private int maxSleepTimeMs = 1000; // // /** // * 重试次数 // */ // private int maxRetries = 3; // // public ZkConfig() { // } // // public ZkConfig(String zkAddress) { // this.zkAddress = zkAddress; // } // // public void setZkAddress(String zkAddress) { // this.zkAddress = zkAddress; // } // // public String getZkAddress() { // return zkAddress; // } // // public int getZkTimeout() { // return zkTimeout; // } // // public void setZkTimeout(int zkTimeout) { // this.zkTimeout = zkTimeout; // } // // public int getBaseSleepTimeMs() { // return baseSleepTimeMs; // } // // public void setBaseSleepTimeMs(int baseSleepTimeMs) { // this.baseSleepTimeMs = baseSleepTimeMs; // } // // public int getMaxSleepTimeMs() { // return maxSleepTimeMs; // } // // public void setMaxSleepTimeMs(int maxSleepTimeMs) { // this.maxSleepTimeMs = maxSleepTimeMs; // } // // public int getMaxRetries() { // return maxRetries; // } // // public void setMaxRetries(int maxRetries) { // this.maxRetries = maxRetries; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerProxyFactory.java // public class ConsumerProxyFactory { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerProxyFactory.class); // // /** // * 正常的业务需求,是保证全局的thrift client 单例的,因为构造client成本是很重的. 这里的,key为class_group_version // */ // private static final ConcurrentHashMap<String, Object> SERVICE_CLIENT_CONCURRENT_HASH_MAP = new ConcurrentHashMap<String, Object>(); // // private static final Joiner CLIENT_KEY_JOINER = Joiner.on("_"); // // private static final Object SERVICE_CLIENT_LOCK = new Object(); // // public <T> T getProxyClient(Class<T> clientClazz, ZkConfig zkConfig) { // return getProxyClient(clientClazz, new ThriftClientConfig(), zkConfig); // } // // @SuppressWarnings("unchecked") // public <T> T getProxyClient(Class<T> clientClazz, ThriftClientConfig config, ZkConfig zkConfig) { // // String clientKey = CLIENT_KEY_JOINER.join(clientClazz.getCanonicalName(), config.getGroup(), // config.getVersion()); // T client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // // if (client == null) { // synchronized (SERVICE_CLIENT_LOCK) { // client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // if (client == null) { // // long start = System.currentTimeMillis(); // final ServiceInfo serviceInfo = new ServiceInfo(clientClazz, config.getVersion(), // config.getGroup()); // // client = (T) Proxy.newProxyInstance(ConsumerProxyFactory.class.getClassLoader(), // new Class[] { clientClazz }, new ConsumerProxy(serviceInfo, zkConfig, config)); // SERVICE_CLIENT_CONCURRENT_HASH_MAP.putIfAbsent(clientKey, client); // LOGGER.info("build thrift client succ.cost:{},clientConfig:{},zkConfig:{}", // System.currentTimeMillis() - start, config, zkConfig); // } // } // } // return client; // } // // } // Path: ourea-core/src/test/java/com/taocoder/ourea/ZkThriftClientSample.java import java.util.Properties; import com.taocoder.ourea.core.common.PropertiesUtils; import com.taocoder.ourea.core.config.ZkConfig; import com.taocoder.ourea.core.consumer.ConsumerProxyFactory; /* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea; /** * @author tao.ke Date: 16/4/27 Time: 下午5:03 */ public class ZkThriftClientSample { public static void main(String[] args) throws Exception {
Properties properties = PropertiesUtils.load("consumer.properties");
ketao1989/ourea
ourea-core/src/test/java/com/taocoder/ourea/ZkThriftClientSample.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/PropertiesUtils.java // public class PropertiesUtils { // // public static Properties load(String fileName) { // // InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); // return load(is); // } // // public static Properties load(InputStream is) { // // Properties properties = new Properties(); // try { // properties.load(is); // } catch (IOException e) { // e.printStackTrace(); // throw new IllegalArgumentException(e.getMessage()); // } // return properties; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ZkConfig.java // public class ZkConfig { // // /** // * zk ip:port, // */ // private String zkAddress; // // /** // * zk 超时时间 // */ // private int zkTimeout = 3000; // // /** // * 重试之间初始等待时间 // */ // private int baseSleepTimeMs = 10; // // /** // * 重试之间最长等待时间 // */ // private int maxSleepTimeMs = 1000; // // /** // * 重试次数 // */ // private int maxRetries = 3; // // public ZkConfig() { // } // // public ZkConfig(String zkAddress) { // this.zkAddress = zkAddress; // } // // public void setZkAddress(String zkAddress) { // this.zkAddress = zkAddress; // } // // public String getZkAddress() { // return zkAddress; // } // // public int getZkTimeout() { // return zkTimeout; // } // // public void setZkTimeout(int zkTimeout) { // this.zkTimeout = zkTimeout; // } // // public int getBaseSleepTimeMs() { // return baseSleepTimeMs; // } // // public void setBaseSleepTimeMs(int baseSleepTimeMs) { // this.baseSleepTimeMs = baseSleepTimeMs; // } // // public int getMaxSleepTimeMs() { // return maxSleepTimeMs; // } // // public void setMaxSleepTimeMs(int maxSleepTimeMs) { // this.maxSleepTimeMs = maxSleepTimeMs; // } // // public int getMaxRetries() { // return maxRetries; // } // // public void setMaxRetries(int maxRetries) { // this.maxRetries = maxRetries; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerProxyFactory.java // public class ConsumerProxyFactory { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerProxyFactory.class); // // /** // * 正常的业务需求,是保证全局的thrift client 单例的,因为构造client成本是很重的. 这里的,key为class_group_version // */ // private static final ConcurrentHashMap<String, Object> SERVICE_CLIENT_CONCURRENT_HASH_MAP = new ConcurrentHashMap<String, Object>(); // // private static final Joiner CLIENT_KEY_JOINER = Joiner.on("_"); // // private static final Object SERVICE_CLIENT_LOCK = new Object(); // // public <T> T getProxyClient(Class<T> clientClazz, ZkConfig zkConfig) { // return getProxyClient(clientClazz, new ThriftClientConfig(), zkConfig); // } // // @SuppressWarnings("unchecked") // public <T> T getProxyClient(Class<T> clientClazz, ThriftClientConfig config, ZkConfig zkConfig) { // // String clientKey = CLIENT_KEY_JOINER.join(clientClazz.getCanonicalName(), config.getGroup(), // config.getVersion()); // T client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // // if (client == null) { // synchronized (SERVICE_CLIENT_LOCK) { // client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // if (client == null) { // // long start = System.currentTimeMillis(); // final ServiceInfo serviceInfo = new ServiceInfo(clientClazz, config.getVersion(), // config.getGroup()); // // client = (T) Proxy.newProxyInstance(ConsumerProxyFactory.class.getClassLoader(), // new Class[] { clientClazz }, new ConsumerProxy(serviceInfo, zkConfig, config)); // SERVICE_CLIENT_CONCURRENT_HASH_MAP.putIfAbsent(clientKey, client); // LOGGER.info("build thrift client succ.cost:{},clientConfig:{},zkConfig:{}", // System.currentTimeMillis() - start, config, zkConfig); // } // } // } // return client; // } // // }
import java.util.Properties; import com.taocoder.ourea.core.common.PropertiesUtils; import com.taocoder.ourea.core.config.ZkConfig; import com.taocoder.ourea.core.consumer.ConsumerProxyFactory;
/* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea; /** * @author tao.ke Date: 16/4/27 Time: 下午5:03 */ public class ZkThriftClientSample { public static void main(String[] args) throws Exception { Properties properties = PropertiesUtils.load("consumer.properties");
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/PropertiesUtils.java // public class PropertiesUtils { // // public static Properties load(String fileName) { // // InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); // return load(is); // } // // public static Properties load(InputStream is) { // // Properties properties = new Properties(); // try { // properties.load(is); // } catch (IOException e) { // e.printStackTrace(); // throw new IllegalArgumentException(e.getMessage()); // } // return properties; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ZkConfig.java // public class ZkConfig { // // /** // * zk ip:port, // */ // private String zkAddress; // // /** // * zk 超时时间 // */ // private int zkTimeout = 3000; // // /** // * 重试之间初始等待时间 // */ // private int baseSleepTimeMs = 10; // // /** // * 重试之间最长等待时间 // */ // private int maxSleepTimeMs = 1000; // // /** // * 重试次数 // */ // private int maxRetries = 3; // // public ZkConfig() { // } // // public ZkConfig(String zkAddress) { // this.zkAddress = zkAddress; // } // // public void setZkAddress(String zkAddress) { // this.zkAddress = zkAddress; // } // // public String getZkAddress() { // return zkAddress; // } // // public int getZkTimeout() { // return zkTimeout; // } // // public void setZkTimeout(int zkTimeout) { // this.zkTimeout = zkTimeout; // } // // public int getBaseSleepTimeMs() { // return baseSleepTimeMs; // } // // public void setBaseSleepTimeMs(int baseSleepTimeMs) { // this.baseSleepTimeMs = baseSleepTimeMs; // } // // public int getMaxSleepTimeMs() { // return maxSleepTimeMs; // } // // public void setMaxSleepTimeMs(int maxSleepTimeMs) { // this.maxSleepTimeMs = maxSleepTimeMs; // } // // public int getMaxRetries() { // return maxRetries; // } // // public void setMaxRetries(int maxRetries) { // this.maxRetries = maxRetries; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerProxyFactory.java // public class ConsumerProxyFactory { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerProxyFactory.class); // // /** // * 正常的业务需求,是保证全局的thrift client 单例的,因为构造client成本是很重的. 这里的,key为class_group_version // */ // private static final ConcurrentHashMap<String, Object> SERVICE_CLIENT_CONCURRENT_HASH_MAP = new ConcurrentHashMap<String, Object>(); // // private static final Joiner CLIENT_KEY_JOINER = Joiner.on("_"); // // private static final Object SERVICE_CLIENT_LOCK = new Object(); // // public <T> T getProxyClient(Class<T> clientClazz, ZkConfig zkConfig) { // return getProxyClient(clientClazz, new ThriftClientConfig(), zkConfig); // } // // @SuppressWarnings("unchecked") // public <T> T getProxyClient(Class<T> clientClazz, ThriftClientConfig config, ZkConfig zkConfig) { // // String clientKey = CLIENT_KEY_JOINER.join(clientClazz.getCanonicalName(), config.getGroup(), // config.getVersion()); // T client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // // if (client == null) { // synchronized (SERVICE_CLIENT_LOCK) { // client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // if (client == null) { // // long start = System.currentTimeMillis(); // final ServiceInfo serviceInfo = new ServiceInfo(clientClazz, config.getVersion(), // config.getGroup()); // // client = (T) Proxy.newProxyInstance(ConsumerProxyFactory.class.getClassLoader(), // new Class[] { clientClazz }, new ConsumerProxy(serviceInfo, zkConfig, config)); // SERVICE_CLIENT_CONCURRENT_HASH_MAP.putIfAbsent(clientKey, client); // LOGGER.info("build thrift client succ.cost:{},clientConfig:{},zkConfig:{}", // System.currentTimeMillis() - start, config, zkConfig); // } // } // } // return client; // } // // } // Path: ourea-core/src/test/java/com/taocoder/ourea/ZkThriftClientSample.java import java.util.Properties; import com.taocoder.ourea.core.common.PropertiesUtils; import com.taocoder.ourea.core.config.ZkConfig; import com.taocoder.ourea.core.consumer.ConsumerProxyFactory; /* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea; /** * @author tao.ke Date: 16/4/27 Time: 下午5:03 */ public class ZkThriftClientSample { public static void main(String[] args) throws Exception { Properties properties = PropertiesUtils.load("consumer.properties");
ConsumerProxyFactory factory = new ConsumerProxyFactory();
ketao1989/ourea
ourea-core/src/test/java/com/taocoder/ourea/ZkThriftClientSample.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/PropertiesUtils.java // public class PropertiesUtils { // // public static Properties load(String fileName) { // // InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); // return load(is); // } // // public static Properties load(InputStream is) { // // Properties properties = new Properties(); // try { // properties.load(is); // } catch (IOException e) { // e.printStackTrace(); // throw new IllegalArgumentException(e.getMessage()); // } // return properties; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ZkConfig.java // public class ZkConfig { // // /** // * zk ip:port, // */ // private String zkAddress; // // /** // * zk 超时时间 // */ // private int zkTimeout = 3000; // // /** // * 重试之间初始等待时间 // */ // private int baseSleepTimeMs = 10; // // /** // * 重试之间最长等待时间 // */ // private int maxSleepTimeMs = 1000; // // /** // * 重试次数 // */ // private int maxRetries = 3; // // public ZkConfig() { // } // // public ZkConfig(String zkAddress) { // this.zkAddress = zkAddress; // } // // public void setZkAddress(String zkAddress) { // this.zkAddress = zkAddress; // } // // public String getZkAddress() { // return zkAddress; // } // // public int getZkTimeout() { // return zkTimeout; // } // // public void setZkTimeout(int zkTimeout) { // this.zkTimeout = zkTimeout; // } // // public int getBaseSleepTimeMs() { // return baseSleepTimeMs; // } // // public void setBaseSleepTimeMs(int baseSleepTimeMs) { // this.baseSleepTimeMs = baseSleepTimeMs; // } // // public int getMaxSleepTimeMs() { // return maxSleepTimeMs; // } // // public void setMaxSleepTimeMs(int maxSleepTimeMs) { // this.maxSleepTimeMs = maxSleepTimeMs; // } // // public int getMaxRetries() { // return maxRetries; // } // // public void setMaxRetries(int maxRetries) { // this.maxRetries = maxRetries; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerProxyFactory.java // public class ConsumerProxyFactory { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerProxyFactory.class); // // /** // * 正常的业务需求,是保证全局的thrift client 单例的,因为构造client成本是很重的. 这里的,key为class_group_version // */ // private static final ConcurrentHashMap<String, Object> SERVICE_CLIENT_CONCURRENT_HASH_MAP = new ConcurrentHashMap<String, Object>(); // // private static final Joiner CLIENT_KEY_JOINER = Joiner.on("_"); // // private static final Object SERVICE_CLIENT_LOCK = new Object(); // // public <T> T getProxyClient(Class<T> clientClazz, ZkConfig zkConfig) { // return getProxyClient(clientClazz, new ThriftClientConfig(), zkConfig); // } // // @SuppressWarnings("unchecked") // public <T> T getProxyClient(Class<T> clientClazz, ThriftClientConfig config, ZkConfig zkConfig) { // // String clientKey = CLIENT_KEY_JOINER.join(clientClazz.getCanonicalName(), config.getGroup(), // config.getVersion()); // T client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // // if (client == null) { // synchronized (SERVICE_CLIENT_LOCK) { // client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // if (client == null) { // // long start = System.currentTimeMillis(); // final ServiceInfo serviceInfo = new ServiceInfo(clientClazz, config.getVersion(), // config.getGroup()); // // client = (T) Proxy.newProxyInstance(ConsumerProxyFactory.class.getClassLoader(), // new Class[] { clientClazz }, new ConsumerProxy(serviceInfo, zkConfig, config)); // SERVICE_CLIENT_CONCURRENT_HASH_MAP.putIfAbsent(clientKey, client); // LOGGER.info("build thrift client succ.cost:{},clientConfig:{},zkConfig:{}", // System.currentTimeMillis() - start, config, zkConfig); // } // } // } // return client; // } // // }
import java.util.Properties; import com.taocoder.ourea.core.common.PropertiesUtils; import com.taocoder.ourea.core.config.ZkConfig; import com.taocoder.ourea.core.consumer.ConsumerProxyFactory;
/* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea; /** * @author tao.ke Date: 16/4/27 Time: 下午5:03 */ public class ZkThriftClientSample { public static void main(String[] args) throws Exception { Properties properties = PropertiesUtils.load("consumer.properties"); ConsumerProxyFactory factory = new ConsumerProxyFactory(); final Ourea.Iface client = factory.getProxyClient(Ourea.Iface.class,
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/PropertiesUtils.java // public class PropertiesUtils { // // public static Properties load(String fileName) { // // InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); // return load(is); // } // // public static Properties load(InputStream is) { // // Properties properties = new Properties(); // try { // properties.load(is); // } catch (IOException e) { // e.printStackTrace(); // throw new IllegalArgumentException(e.getMessage()); // } // return properties; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ZkConfig.java // public class ZkConfig { // // /** // * zk ip:port, // */ // private String zkAddress; // // /** // * zk 超时时间 // */ // private int zkTimeout = 3000; // // /** // * 重试之间初始等待时间 // */ // private int baseSleepTimeMs = 10; // // /** // * 重试之间最长等待时间 // */ // private int maxSleepTimeMs = 1000; // // /** // * 重试次数 // */ // private int maxRetries = 3; // // public ZkConfig() { // } // // public ZkConfig(String zkAddress) { // this.zkAddress = zkAddress; // } // // public void setZkAddress(String zkAddress) { // this.zkAddress = zkAddress; // } // // public String getZkAddress() { // return zkAddress; // } // // public int getZkTimeout() { // return zkTimeout; // } // // public void setZkTimeout(int zkTimeout) { // this.zkTimeout = zkTimeout; // } // // public int getBaseSleepTimeMs() { // return baseSleepTimeMs; // } // // public void setBaseSleepTimeMs(int baseSleepTimeMs) { // this.baseSleepTimeMs = baseSleepTimeMs; // } // // public int getMaxSleepTimeMs() { // return maxSleepTimeMs; // } // // public void setMaxSleepTimeMs(int maxSleepTimeMs) { // this.maxSleepTimeMs = maxSleepTimeMs; // } // // public int getMaxRetries() { // return maxRetries; // } // // public void setMaxRetries(int maxRetries) { // this.maxRetries = maxRetries; // } // // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerProxyFactory.java // public class ConsumerProxyFactory { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerProxyFactory.class); // // /** // * 正常的业务需求,是保证全局的thrift client 单例的,因为构造client成本是很重的. 这里的,key为class_group_version // */ // private static final ConcurrentHashMap<String, Object> SERVICE_CLIENT_CONCURRENT_HASH_MAP = new ConcurrentHashMap<String, Object>(); // // private static final Joiner CLIENT_KEY_JOINER = Joiner.on("_"); // // private static final Object SERVICE_CLIENT_LOCK = new Object(); // // public <T> T getProxyClient(Class<T> clientClazz, ZkConfig zkConfig) { // return getProxyClient(clientClazz, new ThriftClientConfig(), zkConfig); // } // // @SuppressWarnings("unchecked") // public <T> T getProxyClient(Class<T> clientClazz, ThriftClientConfig config, ZkConfig zkConfig) { // // String clientKey = CLIENT_KEY_JOINER.join(clientClazz.getCanonicalName(), config.getGroup(), // config.getVersion()); // T client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // // if (client == null) { // synchronized (SERVICE_CLIENT_LOCK) { // client = (T) SERVICE_CLIENT_CONCURRENT_HASH_MAP.get(clientKey); // if (client == null) { // // long start = System.currentTimeMillis(); // final ServiceInfo serviceInfo = new ServiceInfo(clientClazz, config.getVersion(), // config.getGroup()); // // client = (T) Proxy.newProxyInstance(ConsumerProxyFactory.class.getClassLoader(), // new Class[] { clientClazz }, new ConsumerProxy(serviceInfo, zkConfig, config)); // SERVICE_CLIENT_CONCURRENT_HASH_MAP.putIfAbsent(clientKey, client); // LOGGER.info("build thrift client succ.cost:{},clientConfig:{},zkConfig:{}", // System.currentTimeMillis() - start, config, zkConfig); // } // } // } // return client; // } // // } // Path: ourea-core/src/test/java/com/taocoder/ourea/ZkThriftClientSample.java import java.util.Properties; import com.taocoder.ourea.core.common.PropertiesUtils; import com.taocoder.ourea.core.config.ZkConfig; import com.taocoder.ourea.core.consumer.ConsumerProxyFactory; /* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea; /** * @author tao.ke Date: 16/4/27 Time: 下午5:03 */ public class ZkThriftClientSample { public static void main(String[] args) throws Exception { Properties properties = PropertiesUtils.load("consumer.properties"); ConsumerProxyFactory factory = new ConsumerProxyFactory(); final Ourea.Iface client = factory.getProxyClient(Ourea.Iface.class,
new ZkConfig(properties.getProperty("zkAddress")));
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/AbstractLoadBalanceStrategy.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // }
import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.collections4.CollectionUtils; import java.util.List;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:17 */ public abstract class AbstractLoadBalanceStrategy implements ILoadBalanceStrategy { @Override
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/AbstractLoadBalanceStrategy.java import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.collections4.CollectionUtils; import java.util.List; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:17 */ public abstract class AbstractLoadBalanceStrategy implements ILoadBalanceStrategy { @Override
public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation) {
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/AbstractLoadBalanceStrategy.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // }
import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.collections4.CollectionUtils; import java.util.List;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:17 */ public abstract class AbstractLoadBalanceStrategy implements ILoadBalanceStrategy { @Override
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/AbstractLoadBalanceStrategy.java import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.collections4.CollectionUtils; import java.util.List; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:17 */ public abstract class AbstractLoadBalanceStrategy implements ILoadBalanceStrategy { @Override
public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation) {
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/AbstractLoadBalanceStrategy.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // }
import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.collections4.CollectionUtils; import java.util.List;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:17 */ public abstract class AbstractLoadBalanceStrategy implements ILoadBalanceStrategy { @Override public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation) { if (CollectionUtils.isEmpty(invokeConns)) {
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/AbstractLoadBalanceStrategy.java import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; import org.apache.commons.collections4.CollectionUtils; import java.util.List; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * @author tao.ke Date: 16/3/3 Time: 下午3:17 */ public abstract class AbstractLoadBalanceStrategy implements ILoadBalanceStrategy { @Override public InvokeConn select(List<InvokeConn> invokeConns, Invocation invocation) { if (CollectionUtils.isEmpty(invokeConns)) {
throw new OureaException("no valid provider exist online.");
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java // public class ConsumerPoolFactory implements PooledObjectFactory<TTransport> { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerPoolFactory.class); // // /** // * 服务提供者的信息 // */ // private ProviderInfo providerInfo; // // /** // * 调用服务的超时时间 // */ // private int timeout; // // public ConsumerPoolFactory(ProviderInfo providerInfo, int timeout) { // this.providerInfo = providerInfo; // this.timeout = timeout; // } // // /** // * 这个地方创建连接的时候,如果创建失败,重试一次,还不行则抛出异常,把该节点暂时移除 // * // * @return // * @throws Exception // */ // @Override // public PooledObject<TTransport> makeObject() throws Exception { // TTransport transport = null; // Exception ex = null; // int retryConn = 1; // do { // try { // transport = new TSocket(providerInfo.getIp(), providerInfo.getPort(), timeout); // transport.open(); // ((TSocket) transport).setTimeout(timeout); // return new DefaultPooledObject<TTransport>(transport); // } catch (Exception e) { // ex = e; // } // } while (retryConn-- > 0); // LOGGER.error("make transport object fail.e:", ex); // throw new OureaConnCreateException("make transport object fail." + ex.getMessage()); // } // // @Override // public void destroyObject(PooledObject<TTransport> p) throws Exception { // // try { // TTransport transport = p.getObject(); // if (transport.isOpen()) { // transport.close(); // } // } catch (Exception e) { // LOGGER.error("destroy transport object fail.maybe exist memory leek.e:", e); // throw new OureaException("destroy transport object fail" + e.getMessage()); // } // // } // // @Override // public boolean validateObject(PooledObject<TTransport> p) { // if (p.getObject().isOpen()) { // return true; // } // return false; // } // // @Override // public void activateObject(PooledObject<TTransport> p) throws Exception { // // } // // @Override // public void passivateObject(PooledObject<TTransport> p) throws Exception { // // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/OureaObjectPoolConfig.java // public class OureaObjectPoolConfig extends GenericObjectPoolConfig { // // /** // * 最大连接数 // */ // private int maxTotal = 100; // // /** // * 最大空闲连接数 // */ // private int maxIdle = 32; // // /** // * 最小空闲连接数 // */ // private int minIdle = 10; // // public int getMaxTotal() { // return maxTotal; // } // // public void setMaxTotal(int maxTotal) { // this.maxTotal = maxTotal; // } // // public int getMaxIdle() { // return maxIdle; // } // // public void setMaxIdle(int maxIdle) { // this.maxIdle = maxIdle; // } // // public int getMinIdle() { // return minIdle; // } // // public void setMinIdle(int minIdle) { // this.minIdle = minIdle; // } // // @Override // public OureaObjectPoolConfig clone() { // // return (OureaObjectPoolConfig) super.clone(); // // } // }
import com.taocoder.ourea.core.consumer.ConsumerPoolFactory; import com.taocoder.ourea.core.config.OureaObjectPoolConfig; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.pool2.ObjectPool; import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.apache.thrift.transport.TTransport; import java.io.Serializable;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.model; /** * 对于一个provider server的连接池对象.这个对象很重,所以需要缓存之后在使用 * * @author tao.ke Date: 16/3/3 Time: 下午2:35 */ public class InvokeConn implements Serializable { private static final long serialVersionUID = -805739143582019252L; /** * 服务端的信息ip+port */ private ProviderInfo providerInfo; /** * 和server端的连接池 */ private ObjectPool<TTransport> connPool; /** * 连接池相关配置 */
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java // public class ConsumerPoolFactory implements PooledObjectFactory<TTransport> { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerPoolFactory.class); // // /** // * 服务提供者的信息 // */ // private ProviderInfo providerInfo; // // /** // * 调用服务的超时时间 // */ // private int timeout; // // public ConsumerPoolFactory(ProviderInfo providerInfo, int timeout) { // this.providerInfo = providerInfo; // this.timeout = timeout; // } // // /** // * 这个地方创建连接的时候,如果创建失败,重试一次,还不行则抛出异常,把该节点暂时移除 // * // * @return // * @throws Exception // */ // @Override // public PooledObject<TTransport> makeObject() throws Exception { // TTransport transport = null; // Exception ex = null; // int retryConn = 1; // do { // try { // transport = new TSocket(providerInfo.getIp(), providerInfo.getPort(), timeout); // transport.open(); // ((TSocket) transport).setTimeout(timeout); // return new DefaultPooledObject<TTransport>(transport); // } catch (Exception e) { // ex = e; // } // } while (retryConn-- > 0); // LOGGER.error("make transport object fail.e:", ex); // throw new OureaConnCreateException("make transport object fail." + ex.getMessage()); // } // // @Override // public void destroyObject(PooledObject<TTransport> p) throws Exception { // // try { // TTransport transport = p.getObject(); // if (transport.isOpen()) { // transport.close(); // } // } catch (Exception e) { // LOGGER.error("destroy transport object fail.maybe exist memory leek.e:", e); // throw new OureaException("destroy transport object fail" + e.getMessage()); // } // // } // // @Override // public boolean validateObject(PooledObject<TTransport> p) { // if (p.getObject().isOpen()) { // return true; // } // return false; // } // // @Override // public void activateObject(PooledObject<TTransport> p) throws Exception { // // } // // @Override // public void passivateObject(PooledObject<TTransport> p) throws Exception { // // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/OureaObjectPoolConfig.java // public class OureaObjectPoolConfig extends GenericObjectPoolConfig { // // /** // * 最大连接数 // */ // private int maxTotal = 100; // // /** // * 最大空闲连接数 // */ // private int maxIdle = 32; // // /** // * 最小空闲连接数 // */ // private int minIdle = 10; // // public int getMaxTotal() { // return maxTotal; // } // // public void setMaxTotal(int maxTotal) { // this.maxTotal = maxTotal; // } // // public int getMaxIdle() { // return maxIdle; // } // // public void setMaxIdle(int maxIdle) { // this.maxIdle = maxIdle; // } // // public int getMinIdle() { // return minIdle; // } // // public void setMinIdle(int minIdle) { // this.minIdle = minIdle; // } // // @Override // public OureaObjectPoolConfig clone() { // // return (OureaObjectPoolConfig) super.clone(); // // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java import com.taocoder.ourea.core.consumer.ConsumerPoolFactory; import com.taocoder.ourea.core.config.OureaObjectPoolConfig; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.pool2.ObjectPool; import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.apache.thrift.transport.TTransport; import java.io.Serializable; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.model; /** * 对于一个provider server的连接池对象.这个对象很重,所以需要缓存之后在使用 * * @author tao.ke Date: 16/3/3 Time: 下午2:35 */ public class InvokeConn implements Serializable { private static final long serialVersionUID = -805739143582019252L; /** * 服务端的信息ip+port */ private ProviderInfo providerInfo; /** * 和server端的连接池 */ private ObjectPool<TTransport> connPool; /** * 连接池相关配置 */
private OureaObjectPoolConfig poolConfig;
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java // public class ConsumerPoolFactory implements PooledObjectFactory<TTransport> { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerPoolFactory.class); // // /** // * 服务提供者的信息 // */ // private ProviderInfo providerInfo; // // /** // * 调用服务的超时时间 // */ // private int timeout; // // public ConsumerPoolFactory(ProviderInfo providerInfo, int timeout) { // this.providerInfo = providerInfo; // this.timeout = timeout; // } // // /** // * 这个地方创建连接的时候,如果创建失败,重试一次,还不行则抛出异常,把该节点暂时移除 // * // * @return // * @throws Exception // */ // @Override // public PooledObject<TTransport> makeObject() throws Exception { // TTransport transport = null; // Exception ex = null; // int retryConn = 1; // do { // try { // transport = new TSocket(providerInfo.getIp(), providerInfo.getPort(), timeout); // transport.open(); // ((TSocket) transport).setTimeout(timeout); // return new DefaultPooledObject<TTransport>(transport); // } catch (Exception e) { // ex = e; // } // } while (retryConn-- > 0); // LOGGER.error("make transport object fail.e:", ex); // throw new OureaConnCreateException("make transport object fail." + ex.getMessage()); // } // // @Override // public void destroyObject(PooledObject<TTransport> p) throws Exception { // // try { // TTransport transport = p.getObject(); // if (transport.isOpen()) { // transport.close(); // } // } catch (Exception e) { // LOGGER.error("destroy transport object fail.maybe exist memory leek.e:", e); // throw new OureaException("destroy transport object fail" + e.getMessage()); // } // // } // // @Override // public boolean validateObject(PooledObject<TTransport> p) { // if (p.getObject().isOpen()) { // return true; // } // return false; // } // // @Override // public void activateObject(PooledObject<TTransport> p) throws Exception { // // } // // @Override // public void passivateObject(PooledObject<TTransport> p) throws Exception { // // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/OureaObjectPoolConfig.java // public class OureaObjectPoolConfig extends GenericObjectPoolConfig { // // /** // * 最大连接数 // */ // private int maxTotal = 100; // // /** // * 最大空闲连接数 // */ // private int maxIdle = 32; // // /** // * 最小空闲连接数 // */ // private int minIdle = 10; // // public int getMaxTotal() { // return maxTotal; // } // // public void setMaxTotal(int maxTotal) { // this.maxTotal = maxTotal; // } // // public int getMaxIdle() { // return maxIdle; // } // // public void setMaxIdle(int maxIdle) { // this.maxIdle = maxIdle; // } // // public int getMinIdle() { // return minIdle; // } // // public void setMinIdle(int minIdle) { // this.minIdle = minIdle; // } // // @Override // public OureaObjectPoolConfig clone() { // // return (OureaObjectPoolConfig) super.clone(); // // } // }
import com.taocoder.ourea.core.consumer.ConsumerPoolFactory; import com.taocoder.ourea.core.config.OureaObjectPoolConfig; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.pool2.ObjectPool; import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.apache.thrift.transport.TTransport; import java.io.Serializable;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.model; /** * 对于一个provider server的连接池对象.这个对象很重,所以需要缓存之后在使用 * * @author tao.ke Date: 16/3/3 Time: 下午2:35 */ public class InvokeConn implements Serializable { private static final long serialVersionUID = -805739143582019252L; /** * 服务端的信息ip+port */ private ProviderInfo providerInfo; /** * 和server端的连接池 */ private ObjectPool<TTransport> connPool; /** * 连接池相关配置 */ private OureaObjectPoolConfig poolConfig; public InvokeConn(ProviderInfo providerInfo, int timeout) { this(providerInfo, timeout, new OureaObjectPoolConfig()); } public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { this.providerInfo = providerInfo; this.poolConfig = poolConfig;
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java // public class ConsumerPoolFactory implements PooledObjectFactory<TTransport> { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerPoolFactory.class); // // /** // * 服务提供者的信息 // */ // private ProviderInfo providerInfo; // // /** // * 调用服务的超时时间 // */ // private int timeout; // // public ConsumerPoolFactory(ProviderInfo providerInfo, int timeout) { // this.providerInfo = providerInfo; // this.timeout = timeout; // } // // /** // * 这个地方创建连接的时候,如果创建失败,重试一次,还不行则抛出异常,把该节点暂时移除 // * // * @return // * @throws Exception // */ // @Override // public PooledObject<TTransport> makeObject() throws Exception { // TTransport transport = null; // Exception ex = null; // int retryConn = 1; // do { // try { // transport = new TSocket(providerInfo.getIp(), providerInfo.getPort(), timeout); // transport.open(); // ((TSocket) transport).setTimeout(timeout); // return new DefaultPooledObject<TTransport>(transport); // } catch (Exception e) { // ex = e; // } // } while (retryConn-- > 0); // LOGGER.error("make transport object fail.e:", ex); // throw new OureaConnCreateException("make transport object fail." + ex.getMessage()); // } // // @Override // public void destroyObject(PooledObject<TTransport> p) throws Exception { // // try { // TTransport transport = p.getObject(); // if (transport.isOpen()) { // transport.close(); // } // } catch (Exception e) { // LOGGER.error("destroy transport object fail.maybe exist memory leek.e:", e); // throw new OureaException("destroy transport object fail" + e.getMessage()); // } // // } // // @Override // public boolean validateObject(PooledObject<TTransport> p) { // if (p.getObject().isOpen()) { // return true; // } // return false; // } // // @Override // public void activateObject(PooledObject<TTransport> p) throws Exception { // // } // // @Override // public void passivateObject(PooledObject<TTransport> p) throws Exception { // // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/OureaObjectPoolConfig.java // public class OureaObjectPoolConfig extends GenericObjectPoolConfig { // // /** // * 最大连接数 // */ // private int maxTotal = 100; // // /** // * 最大空闲连接数 // */ // private int maxIdle = 32; // // /** // * 最小空闲连接数 // */ // private int minIdle = 10; // // public int getMaxTotal() { // return maxTotal; // } // // public void setMaxTotal(int maxTotal) { // this.maxTotal = maxTotal; // } // // public int getMaxIdle() { // return maxIdle; // } // // public void setMaxIdle(int maxIdle) { // this.maxIdle = maxIdle; // } // // public int getMinIdle() { // return minIdle; // } // // public void setMinIdle(int minIdle) { // this.minIdle = minIdle; // } // // @Override // public OureaObjectPoolConfig clone() { // // return (OureaObjectPoolConfig) super.clone(); // // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java import com.taocoder.ourea.core.consumer.ConsumerPoolFactory; import com.taocoder.ourea.core.config.OureaObjectPoolConfig; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.pool2.ObjectPool; import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import org.apache.thrift.transport.TTransport; import java.io.Serializable; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.model; /** * 对于一个provider server的连接池对象.这个对象很重,所以需要缓存之后在使用 * * @author tao.ke Date: 16/3/3 Time: 下午2:35 */ public class InvokeConn implements Serializable { private static final long serialVersionUID = -805739143582019252L; /** * 服务端的信息ip+port */ private ProviderInfo providerInfo; /** * 和server端的连接池 */ private ObjectPool<TTransport> connPool; /** * 连接池相关配置 */ private OureaObjectPoolConfig poolConfig; public InvokeConn(ProviderInfo providerInfo, int timeout) { this(providerInfo, timeout, new OureaObjectPoolConfig()); } public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { this.providerInfo = providerInfo; this.poolConfig = poolConfig;
this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig);
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // }
import java.util.List; import java.util.concurrent.ConcurrentHashMap; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * 根据方法级别进行轮询调用.不考虑权重 * * @author tao.ke Date: 16/3/3 Time: 下午3:39 */ public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy { private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>(); @Override
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java import java.util.List; import java.util.concurrent.ConcurrentHashMap; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * 根据方法级别进行轮询调用.不考虑权重 * * @author tao.ke Date: 16/3/3 Time: 下午3:39 */ public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy { private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>(); @Override
protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) {
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // }
import java.util.List; import java.util.concurrent.ConcurrentHashMap; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn;
/* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * 根据方法级别进行轮询调用.不考虑权重 * * @author tao.ke Date: 16/3/3 Time: 下午3:39 */ public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy { private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>(); @Override
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/Invocation.java // public class Invocation implements Serializable { // // private static final long serialVersionUID = 3518301260123528398L; // // private String interfaceName; // // private String methodName; // // public Invocation() { // } // // public Invocation(String interfaceName, String methodName) { // this.interfaceName = interfaceName; // this.methodName = methodName; // } // // public String getInterfaceName() { // return interfaceName; // } // // public void setInterfaceName(String interfaceName) { // this.interfaceName = interfaceName; // } // // public String getMethodName() { // return methodName; // } // // public void setMethodName(String methodName) { // this.methodName = methodName; // } // // @Override // public boolean equals(Object o) { // if (this == o) // return true; // // if (o == null || getClass() != o.getClass()) // return false; // // Invocation that = (Invocation) o; // // return new EqualsBuilder().append(interfaceName, that.interfaceName).append(methodName, that.methodName) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(interfaceName).append(methodName).toHashCode(); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/InvokeConn.java // public class InvokeConn implements Serializable { // // private static final long serialVersionUID = -805739143582019252L; // // /** // * 服务端的信息ip+port // */ // private ProviderInfo providerInfo; // // /** // * 和server端的连接池 // */ // private ObjectPool<TTransport> connPool; // // /** // * 连接池相关配置 // */ // private OureaObjectPoolConfig poolConfig; // // public InvokeConn(ProviderInfo providerInfo, int timeout) { // this(providerInfo, timeout, new OureaObjectPoolConfig()); // } // // public InvokeConn(ProviderInfo providerInfo, int timeout, OureaObjectPoolConfig poolConfig) { // this.providerInfo = providerInfo; // this.poolConfig = poolConfig; // this.connPool = new GenericObjectPool<TTransport>(new ConsumerPoolFactory(providerInfo, timeout), poolConfig); // } // // public ProviderInfo getProviderInfo() { // return providerInfo; // } // // public void setProviderInfo(ProviderInfo providerInfo) { // this.providerInfo = providerInfo; // } // // public ObjectPool<TTransport> getConnPool() { // return connPool; // } // // public GenericObjectPoolConfig getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(OureaObjectPoolConfig poolConfig) { // this.poolConfig = poolConfig; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // // if (o == null || getClass() != o.getClass()) return false; // // InvokeConn conn = (InvokeConn) o; // // return new EqualsBuilder() // .append(providerInfo, conn.providerInfo) // .isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37) // .append(providerInfo) // .toHashCode(); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/loadbalance/RoundRobinLoadBalanceStrategy.java import java.util.List; import java.util.concurrent.ConcurrentHashMap; import com.taocoder.ourea.core.model.Invocation; import com.taocoder.ourea.core.model.InvokeConn; /* * Copyright (c) 2015 ketao1989.github.com. All Rights Reserved. */ package com.taocoder.ourea.core.loadbalance; /** * 根据方法级别进行轮询调用.不考虑权重 * * @author tao.ke Date: 16/3/3 Time: 下午3:39 */ public class RoundRobinLoadBalanceStrategy extends AbstractLoadBalanceStrategy { private static final ConcurrentHashMap<String, Integer> current = new ConcurrentHashMap<String, Integer>(); @Override
protected InvokeConn doSelect(List<InvokeConn> invokeConns, Invocation invocation) {
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaConnCreateException.java // public class OureaConnCreateException extends RuntimeException { // // public OureaConnCreateException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/ProviderInfo.java // public class ProviderInfo implements Serializable { // // private static final long serialVersionUID = 733316025823163238L; // // private String ip; // private int port; // private int weight; // // /** // * 是否对外提供服务 // */ // private boolean status = true; // // public ProviderInfo() { // } // // public ProviderInfo(String ip) { // this.ip = ip; // } // // public String getIp() { // return ip; // } // // public void setIp(String ip) { // this.ip = ip; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // public int getWeight() { // return weight; // } // // public void setWeight(int weight) { // this.weight = weight; // } // // public boolean isStatus() { // return status; // } // // public void setStatus(boolean status) { // this.status = status; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // // if (o == null || getClass() != o.getClass()) { // return false; // } // // ProviderInfo that = (ProviderInfo) o; // // return new EqualsBuilder().append(port, that.port).append(ip, that.ip).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(ip).append(port).toHashCode(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); // } // }
import com.taocoder.ourea.core.common.OureaConnCreateException; import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.ProviderInfo; import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.PooledObjectFactory; import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
/* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.consumer; /** * @author tao.ke Date: 16/4/25 Time: 下午4:46 */ public class ConsumerPoolFactory implements PooledObjectFactory<TTransport> { private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerPoolFactory.class); /** * 服务提供者的信息 */
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaConnCreateException.java // public class OureaConnCreateException extends RuntimeException { // // public OureaConnCreateException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/ProviderInfo.java // public class ProviderInfo implements Serializable { // // private static final long serialVersionUID = 733316025823163238L; // // private String ip; // private int port; // private int weight; // // /** // * 是否对外提供服务 // */ // private boolean status = true; // // public ProviderInfo() { // } // // public ProviderInfo(String ip) { // this.ip = ip; // } // // public String getIp() { // return ip; // } // // public void setIp(String ip) { // this.ip = ip; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // public int getWeight() { // return weight; // } // // public void setWeight(int weight) { // this.weight = weight; // } // // public boolean isStatus() { // return status; // } // // public void setStatus(boolean status) { // this.status = status; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // // if (o == null || getClass() != o.getClass()) { // return false; // } // // ProviderInfo that = (ProviderInfo) o; // // return new EqualsBuilder().append(port, that.port).append(ip, that.ip).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(ip).append(port).toHashCode(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java import com.taocoder.ourea.core.common.OureaConnCreateException; import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.ProviderInfo; import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.PooledObjectFactory; import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.consumer; /** * @author tao.ke Date: 16/4/25 Time: 下午4:46 */ public class ConsumerPoolFactory implements PooledObjectFactory<TTransport> { private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerPoolFactory.class); /** * 服务提供者的信息 */
private ProviderInfo providerInfo;
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaConnCreateException.java // public class OureaConnCreateException extends RuntimeException { // // public OureaConnCreateException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/ProviderInfo.java // public class ProviderInfo implements Serializable { // // private static final long serialVersionUID = 733316025823163238L; // // private String ip; // private int port; // private int weight; // // /** // * 是否对外提供服务 // */ // private boolean status = true; // // public ProviderInfo() { // } // // public ProviderInfo(String ip) { // this.ip = ip; // } // // public String getIp() { // return ip; // } // // public void setIp(String ip) { // this.ip = ip; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // public int getWeight() { // return weight; // } // // public void setWeight(int weight) { // this.weight = weight; // } // // public boolean isStatus() { // return status; // } // // public void setStatus(boolean status) { // this.status = status; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // // if (o == null || getClass() != o.getClass()) { // return false; // } // // ProviderInfo that = (ProviderInfo) o; // // return new EqualsBuilder().append(port, that.port).append(ip, that.ip).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(ip).append(port).toHashCode(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); // } // }
import com.taocoder.ourea.core.common.OureaConnCreateException; import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.ProviderInfo; import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.PooledObjectFactory; import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
/* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.consumer; /** * @author tao.ke Date: 16/4/25 Time: 下午4:46 */ public class ConsumerPoolFactory implements PooledObjectFactory<TTransport> { private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerPoolFactory.class); /** * 服务提供者的信息 */ private ProviderInfo providerInfo; /** * 调用服务的超时时间 */ private int timeout; public ConsumerPoolFactory(ProviderInfo providerInfo, int timeout) { this.providerInfo = providerInfo; this.timeout = timeout; } /** * 这个地方创建连接的时候,如果创建失败,重试一次,还不行则抛出异常,把该节点暂时移除 * * @return * @throws Exception */ @Override public PooledObject<TTransport> makeObject() throws Exception { TTransport transport = null; Exception ex = null; int retryConn = 1; do { try { transport = new TSocket(providerInfo.getIp(), providerInfo.getPort(), timeout); transport.open(); ((TSocket) transport).setTimeout(timeout); return new DefaultPooledObject<TTransport>(transport); } catch (Exception e) { ex = e; } } while (retryConn-- > 0); LOGGER.error("make transport object fail.e:", ex);
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaConnCreateException.java // public class OureaConnCreateException extends RuntimeException { // // public OureaConnCreateException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/ProviderInfo.java // public class ProviderInfo implements Serializable { // // private static final long serialVersionUID = 733316025823163238L; // // private String ip; // private int port; // private int weight; // // /** // * 是否对外提供服务 // */ // private boolean status = true; // // public ProviderInfo() { // } // // public ProviderInfo(String ip) { // this.ip = ip; // } // // public String getIp() { // return ip; // } // // public void setIp(String ip) { // this.ip = ip; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // public int getWeight() { // return weight; // } // // public void setWeight(int weight) { // this.weight = weight; // } // // public boolean isStatus() { // return status; // } // // public void setStatus(boolean status) { // this.status = status; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // // if (o == null || getClass() != o.getClass()) { // return false; // } // // ProviderInfo that = (ProviderInfo) o; // // return new EqualsBuilder().append(port, that.port).append(ip, that.ip).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(ip).append(port).toHashCode(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java import com.taocoder.ourea.core.common.OureaConnCreateException; import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.ProviderInfo; import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.PooledObjectFactory; import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.consumer; /** * @author tao.ke Date: 16/4/25 Time: 下午4:46 */ public class ConsumerPoolFactory implements PooledObjectFactory<TTransport> { private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerPoolFactory.class); /** * 服务提供者的信息 */ private ProviderInfo providerInfo; /** * 调用服务的超时时间 */ private int timeout; public ConsumerPoolFactory(ProviderInfo providerInfo, int timeout) { this.providerInfo = providerInfo; this.timeout = timeout; } /** * 这个地方创建连接的时候,如果创建失败,重试一次,还不行则抛出异常,把该节点暂时移除 * * @return * @throws Exception */ @Override public PooledObject<TTransport> makeObject() throws Exception { TTransport transport = null; Exception ex = null; int retryConn = 1; do { try { transport = new TSocket(providerInfo.getIp(), providerInfo.getPort(), timeout); transport.open(); ((TSocket) transport).setTimeout(timeout); return new DefaultPooledObject<TTransport>(transport); } catch (Exception e) { ex = e; } } while (retryConn-- > 0); LOGGER.error("make transport object fail.e:", ex);
throw new OureaConnCreateException("make transport object fail." + ex.getMessage());
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaConnCreateException.java // public class OureaConnCreateException extends RuntimeException { // // public OureaConnCreateException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/ProviderInfo.java // public class ProviderInfo implements Serializable { // // private static final long serialVersionUID = 733316025823163238L; // // private String ip; // private int port; // private int weight; // // /** // * 是否对外提供服务 // */ // private boolean status = true; // // public ProviderInfo() { // } // // public ProviderInfo(String ip) { // this.ip = ip; // } // // public String getIp() { // return ip; // } // // public void setIp(String ip) { // this.ip = ip; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // public int getWeight() { // return weight; // } // // public void setWeight(int weight) { // this.weight = weight; // } // // public boolean isStatus() { // return status; // } // // public void setStatus(boolean status) { // this.status = status; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // // if (o == null || getClass() != o.getClass()) { // return false; // } // // ProviderInfo that = (ProviderInfo) o; // // return new EqualsBuilder().append(port, that.port).append(ip, that.ip).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(ip).append(port).toHashCode(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); // } // }
import com.taocoder.ourea.core.common.OureaConnCreateException; import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.ProviderInfo; import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.PooledObjectFactory; import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
*/ @Override public PooledObject<TTransport> makeObject() throws Exception { TTransport transport = null; Exception ex = null; int retryConn = 1; do { try { transport = new TSocket(providerInfo.getIp(), providerInfo.getPort(), timeout); transport.open(); ((TSocket) transport).setTimeout(timeout); return new DefaultPooledObject<TTransport>(transport); } catch (Exception e) { ex = e; } } while (retryConn-- > 0); LOGGER.error("make transport object fail.e:", ex); throw new OureaConnCreateException("make transport object fail." + ex.getMessage()); } @Override public void destroyObject(PooledObject<TTransport> p) throws Exception { try { TTransport transport = p.getObject(); if (transport.isOpen()) { transport.close(); } } catch (Exception e) { LOGGER.error("destroy transport object fail.maybe exist memory leek.e:", e);
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaConnCreateException.java // public class OureaConnCreateException extends RuntimeException { // // public OureaConnCreateException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/OureaException.java // public class OureaException extends RuntimeException { // // public OureaException(String message) { // super(message); // } // } // // Path: ourea-core/src/main/java/com/taocoder/ourea/core/model/ProviderInfo.java // public class ProviderInfo implements Serializable { // // private static final long serialVersionUID = 733316025823163238L; // // private String ip; // private int port; // private int weight; // // /** // * 是否对外提供服务 // */ // private boolean status = true; // // public ProviderInfo() { // } // // public ProviderInfo(String ip) { // this.ip = ip; // } // // public String getIp() { // return ip; // } // // public void setIp(String ip) { // this.ip = ip; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // public int getWeight() { // return weight; // } // // public void setWeight(int weight) { // this.weight = weight; // } // // public boolean isStatus() { // return status; // } // // public void setStatus(boolean status) { // this.status = status; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // // if (o == null || getClass() != o.getClass()) { // return false; // } // // ProviderInfo that = (ProviderInfo) o; // // return new EqualsBuilder().append(port, that.port).append(ip, that.ip).isEquals(); // } // // @Override // public int hashCode() { // return new HashCodeBuilder(17, 37).append(ip).append(port).toHashCode(); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); // } // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/consumer/ConsumerPoolFactory.java import com.taocoder.ourea.core.common.OureaConnCreateException; import com.taocoder.ourea.core.common.OureaException; import com.taocoder.ourea.core.model.ProviderInfo; import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.PooledObjectFactory; import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.slf4j.Logger; import org.slf4j.LoggerFactory; */ @Override public PooledObject<TTransport> makeObject() throws Exception { TTransport transport = null; Exception ex = null; int retryConn = 1; do { try { transport = new TSocket(providerInfo.getIp(), providerInfo.getPort(), timeout); transport.open(); ((TSocket) transport).setTimeout(timeout); return new DefaultPooledObject<TTransport>(transport); } catch (Exception e) { ex = e; } } while (retryConn-- > 0); LOGGER.error("make transport object fail.e:", ex); throw new OureaConnCreateException("make transport object fail." + ex.getMessage()); } @Override public void destroyObject(PooledObject<TTransport> p) throws Exception { try { TTransport transport = p.getObject(); if (transport.isOpen()) { transport.close(); } } catch (Exception e) { LOGGER.error("destroy transport object fail.maybe exist memory leek.e:", e);
throw new OureaException("destroy transport object fail" + e.getMessage());
ketao1989/ourea
ourea-core/src/main/java/com/taocoder/ourea/core/config/ThriftServerConfig.java
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/Constants.java // public class Constants { // // public static final String ZK_PATH_PREFIX = "/ourea"; // // public static final String PATH_SEPARATOR = "/"; // // public static final String GROUP_KEY = "group"; // // public static final String VERSION_KEY = "version"; // // public static final String INTERFACE_KEY = "interface"; // // public static final String INVOKER_KEY = "invoker"; // // public static final String DEFAULT_INVOKER_PROVIDER = "provider"; // // public static final String DEFAULT_INVOKER_CONSUMER = "consumer"; // // public static final String DEFAULT_GROUP_NAME = "ourea"; // // public static final String DEFAULT_VERSION_VALUE = "1.0.0"; // // public static final int DEFAULT_WEIGHT_VALUE = 0; // // public static final int DEFAULT_TIMEOUT_VALUE = 1000; // // public static final int DEFAULT_THRIFT_PORT = 1000; // }
import com.taocoder.ourea.core.common.Constants; import org.apache.thrift.server.TServerEventHandler;
/* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.config; /** * thrift 服务端相关配置 * * @author tao.ke Date: 16/4/28 Time: 上午10:53 */ public class ThriftServerConfig { /** * 端口号 */ private int port; /** * server最小工作线程数 */ private int MinWorkerThreads = 10; /** * server最大工作线程数 */ private int MaxWorkerThreads = 64; /** * server service 组 */
// Path: ourea-core/src/main/java/com/taocoder/ourea/core/common/Constants.java // public class Constants { // // public static final String ZK_PATH_PREFIX = "/ourea"; // // public static final String PATH_SEPARATOR = "/"; // // public static final String GROUP_KEY = "group"; // // public static final String VERSION_KEY = "version"; // // public static final String INTERFACE_KEY = "interface"; // // public static final String INVOKER_KEY = "invoker"; // // public static final String DEFAULT_INVOKER_PROVIDER = "provider"; // // public static final String DEFAULT_INVOKER_CONSUMER = "consumer"; // // public static final String DEFAULT_GROUP_NAME = "ourea"; // // public static final String DEFAULT_VERSION_VALUE = "1.0.0"; // // public static final int DEFAULT_WEIGHT_VALUE = 0; // // public static final int DEFAULT_TIMEOUT_VALUE = 1000; // // public static final int DEFAULT_THRIFT_PORT = 1000; // } // Path: ourea-core/src/main/java/com/taocoder/ourea/core/config/ThriftServerConfig.java import com.taocoder.ourea.core.common.Constants; import org.apache.thrift.server.TServerEventHandler; /* * Copyright (c) 2015 taocoder.com. All Rights Reserved. */ package com.taocoder.ourea.core.config; /** * thrift 服务端相关配置 * * @author tao.ke Date: 16/4/28 Time: 上午10:53 */ public class ThriftServerConfig { /** * 端口号 */ private int port; /** * server最小工作线程数 */ private int MinWorkerThreads = 10; /** * server最大工作线程数 */ private int MaxWorkerThreads = 64; /** * server service 组 */
private String group = Constants.DEFAULT_GROUP_NAME;
JeffreyFalgout/ThrowingStream
throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/terminal/ThrowingBaseStreamTerminal.java
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingBaseSpliterator.java // public interface ThrowingBaseSpliterator<E, X extends Throwable, S extends ThrowingBaseSpliterator<E, X, S>> { // public static interface ThrowingSpliterator<E, X extends Throwable> // extends ThrowingBaseSpliterator<E, X, ThrowingSpliterator<E, X>> {} // // public static interface OfPrimitive<E, E_CONS, X extends Throwable, S extends OfPrimitive<E, E_CONS, X, S>> // extends ThrowingBaseSpliterator<E, X, S> { // public boolean tryAdvance(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X, OfInt<X>> { // default public boolean normalTryAdvance(IntConsumer action) throws X { // return tryAdvance((ThrowingIntConsumer<? extends X>) action::accept); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X, OfLong<X>> { // default public boolean normalTryAdvance(LongConsumer action) throws X { // return tryAdvance((ThrowingLongConsumer<? extends X>) action::accept); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X, OfDouble<X>> { // default public boolean normalTryAdvance(DoubleConsumer action) throws X { // return tryAdvance((ThrowingDoubleConsumer<? extends X>) action::accept); // } // } // // default public boolean normalTryAdvance(Consumer<? super E> action) throws X { // return tryAdvance(action::accept); // } // // public boolean tryAdvance(ThrowingConsumer<? super E, ? extends X> action) throws X; // // public S trySplit(); // // public long estimateSize(); // // public int characteristics(); // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingIterator.java // public interface ThrowingIterator<E, X extends Throwable> { // public static interface OfPrimitive<E, E_CONS, X extends Throwable> // extends ThrowingIterator<E, X> { // public void forEachRemaining(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X> { // public int nextInt() throws X; // // @Override // default public Integer next() throws X { // return nextInt(); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X> { // public long nextLong() throws X; // // @Override // default public Long next() throws X { // return nextLong(); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X> { // public double nextDouble() throws X; // // @Override // default public Double next() throws X { // return nextDouble(); // } // } // // public E next() throws X; // // public boolean hasNext() throws X; // // default public void remove() throws X { // throw new UnsupportedOperationException(); // } // // public void forEachRemaining(ThrowingConsumer<? super E, ? extends X> action) throws X; // }
import name.falgout.jeffrey.throwing.ThrowingBaseSpliterator; import name.falgout.jeffrey.throwing.ThrowingIterator;
package name.falgout.jeffrey.throwing.stream.terminal; public interface ThrowingBaseStreamTerminal<T, X extends Throwable> { public ThrowingIterator<T, X> iterator();
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingBaseSpliterator.java // public interface ThrowingBaseSpliterator<E, X extends Throwable, S extends ThrowingBaseSpliterator<E, X, S>> { // public static interface ThrowingSpliterator<E, X extends Throwable> // extends ThrowingBaseSpliterator<E, X, ThrowingSpliterator<E, X>> {} // // public static interface OfPrimitive<E, E_CONS, X extends Throwable, S extends OfPrimitive<E, E_CONS, X, S>> // extends ThrowingBaseSpliterator<E, X, S> { // public boolean tryAdvance(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X, OfInt<X>> { // default public boolean normalTryAdvance(IntConsumer action) throws X { // return tryAdvance((ThrowingIntConsumer<? extends X>) action::accept); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X, OfLong<X>> { // default public boolean normalTryAdvance(LongConsumer action) throws X { // return tryAdvance((ThrowingLongConsumer<? extends X>) action::accept); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X, OfDouble<X>> { // default public boolean normalTryAdvance(DoubleConsumer action) throws X { // return tryAdvance((ThrowingDoubleConsumer<? extends X>) action::accept); // } // } // // default public boolean normalTryAdvance(Consumer<? super E> action) throws X { // return tryAdvance(action::accept); // } // // public boolean tryAdvance(ThrowingConsumer<? super E, ? extends X> action) throws X; // // public S trySplit(); // // public long estimateSize(); // // public int characteristics(); // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingIterator.java // public interface ThrowingIterator<E, X extends Throwable> { // public static interface OfPrimitive<E, E_CONS, X extends Throwable> // extends ThrowingIterator<E, X> { // public void forEachRemaining(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X> { // public int nextInt() throws X; // // @Override // default public Integer next() throws X { // return nextInt(); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X> { // public long nextLong() throws X; // // @Override // default public Long next() throws X { // return nextLong(); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X> { // public double nextDouble() throws X; // // @Override // default public Double next() throws X { // return nextDouble(); // } // } // // public E next() throws X; // // public boolean hasNext() throws X; // // default public void remove() throws X { // throw new UnsupportedOperationException(); // } // // public void forEachRemaining(ThrowingConsumer<? super E, ? extends X> action) throws X; // } // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/terminal/ThrowingBaseStreamTerminal.java import name.falgout.jeffrey.throwing.ThrowingBaseSpliterator; import name.falgout.jeffrey.throwing.ThrowingIterator; package name.falgout.jeffrey.throwing.stream.terminal; public interface ThrowingBaseStreamTerminal<T, X extends Throwable> { public ThrowingIterator<T, X> iterator();
public ThrowingBaseSpliterator<T, X, ?> spliterator();
JeffreyFalgout/ThrowingStream
throwing-interfaces/src/test/java/name/falgout/jeffrey/throwing/stream/ThrowingLambdasTest.java
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/Nothing.java // public final class Nothing extends RuntimeException { // private static final long serialVersionUID = -5459023265330371793L; // // private Nothing() { // throw new Error("No instances!"); // } // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingSupplier.java // @FunctionalInterface // public interface ThrowingSupplier<R, X extends Throwable> { // public R get() throws X; // // default public Supplier<R> fallbackTo(Supplier<? extends R> fallback) { // return fallbackTo(fallback, null); // } // // default public Supplier<R> fallbackTo(Supplier<? extends R> fallback, // @Nullable Consumer<? super Throwable> thrown) { // ThrowingSupplier<R, Nothing> t = fallback::get; // return orTry(t, thrown)::get; // } // // default public <Y extends Throwable> ThrowingSupplier<R, Y> // orTry(ThrowingSupplier<? extends R, ? extends Y> supplier) { // return orTry(supplier, null); // } // // default public <Y extends Throwable> ThrowingSupplier<R, Y> orTry( // ThrowingSupplier<? extends R, ? extends Y> supplier, // @Nullable Consumer<? super Throwable> thrown) { // Objects.requireNonNull(supplier, "supplier"); // return () -> { // try { // return get(); // } catch (Throwable x) { // if (thrown != null) { // thrown.accept(x); // } // // try { // return supplier.get(); // } catch (Throwable y) { // y.addSuppressed(x); // throw y; // } // } // }; // } // // default public <Y extends Throwable> ThrowingSupplier<R, Y> rethrow(Class<X> x, // Function<? super X, ? extends Y> mapper) { // Function<Throwable, ? extends Y> rethrower = RethrowChain.castTo(x).rethrow(mapper).finish(); // return () -> { // try { // return get(); // } catch (Throwable t) { // throw rethrower.apply(t); // } // }; // } // }
import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import java.io.IOException; import java.util.function.Supplier; import org.junit.Test; import org.mockito.InOrder; import name.falgout.jeffrey.throwing.Nothing; import name.falgout.jeffrey.throwing.ThrowingSupplier;
package name.falgout.jeffrey.throwing.stream; public class ThrowingLambdasTest { private <X extends Throwable> ThrowingSupplier<Object, X> failure(Runnable callback, X x) { return () -> { if (callback != null) { callback.run(); } throw x; }; } private <X extends Throwable> ThrowingSupplier<Object, X> success() { Object o = new Object(); return () -> o; } @Test public void fallbackFailureTest() { IOException e = new IOException("foo"); Runnable mock = mock(Runnable.class); ThrowingSupplier<Object, IOException> s = failure(mock, e);
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/Nothing.java // public final class Nothing extends RuntimeException { // private static final long serialVersionUID = -5459023265330371793L; // // private Nothing() { // throw new Error("No instances!"); // } // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingSupplier.java // @FunctionalInterface // public interface ThrowingSupplier<R, X extends Throwable> { // public R get() throws X; // // default public Supplier<R> fallbackTo(Supplier<? extends R> fallback) { // return fallbackTo(fallback, null); // } // // default public Supplier<R> fallbackTo(Supplier<? extends R> fallback, // @Nullable Consumer<? super Throwable> thrown) { // ThrowingSupplier<R, Nothing> t = fallback::get; // return orTry(t, thrown)::get; // } // // default public <Y extends Throwable> ThrowingSupplier<R, Y> // orTry(ThrowingSupplier<? extends R, ? extends Y> supplier) { // return orTry(supplier, null); // } // // default public <Y extends Throwable> ThrowingSupplier<R, Y> orTry( // ThrowingSupplier<? extends R, ? extends Y> supplier, // @Nullable Consumer<? super Throwable> thrown) { // Objects.requireNonNull(supplier, "supplier"); // return () -> { // try { // return get(); // } catch (Throwable x) { // if (thrown != null) { // thrown.accept(x); // } // // try { // return supplier.get(); // } catch (Throwable y) { // y.addSuppressed(x); // throw y; // } // } // }; // } // // default public <Y extends Throwable> ThrowingSupplier<R, Y> rethrow(Class<X> x, // Function<? super X, ? extends Y> mapper) { // Function<Throwable, ? extends Y> rethrower = RethrowChain.castTo(x).rethrow(mapper).finish(); // return () -> { // try { // return get(); // } catch (Throwable t) { // throw rethrower.apply(t); // } // }; // } // } // Path: throwing-interfaces/src/test/java/name/falgout/jeffrey/throwing/stream/ThrowingLambdasTest.java import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import java.io.IOException; import java.util.function.Supplier; import org.junit.Test; import org.mockito.InOrder; import name.falgout.jeffrey.throwing.Nothing; import name.falgout.jeffrey.throwing.ThrowingSupplier; package name.falgout.jeffrey.throwing.stream; public class ThrowingLambdasTest { private <X extends Throwable> ThrowingSupplier<Object, X> failure(Runnable callback, X x) { return () -> { if (callback != null) { callback.run(); } throw x; }; } private <X extends Throwable> ThrowingSupplier<Object, X> success() { Object o = new Object(); return () -> o; } @Test public void fallbackFailureTest() { IOException e = new IOException("foo"); Runnable mock = mock(Runnable.class); ThrowingSupplier<Object, IOException> s = failure(mock, e);
Supplier<Object> fallback = this.<Nothing> success()::get;
JeffreyFalgout/ThrowingStream
throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/ThrowingBaseStream.java
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingBaseSpliterator.java // public interface ThrowingBaseSpliterator<E, X extends Throwable, S extends ThrowingBaseSpliterator<E, X, S>> { // public static interface ThrowingSpliterator<E, X extends Throwable> // extends ThrowingBaseSpliterator<E, X, ThrowingSpliterator<E, X>> {} // // public static interface OfPrimitive<E, E_CONS, X extends Throwable, S extends OfPrimitive<E, E_CONS, X, S>> // extends ThrowingBaseSpliterator<E, X, S> { // public boolean tryAdvance(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X, OfInt<X>> { // default public boolean normalTryAdvance(IntConsumer action) throws X { // return tryAdvance((ThrowingIntConsumer<? extends X>) action::accept); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X, OfLong<X>> { // default public boolean normalTryAdvance(LongConsumer action) throws X { // return tryAdvance((ThrowingLongConsumer<? extends X>) action::accept); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X, OfDouble<X>> { // default public boolean normalTryAdvance(DoubleConsumer action) throws X { // return tryAdvance((ThrowingDoubleConsumer<? extends X>) action::accept); // } // } // // default public boolean normalTryAdvance(Consumer<? super E> action) throws X { // return tryAdvance(action::accept); // } // // public boolean tryAdvance(ThrowingConsumer<? super E, ? extends X> action) throws X; // // public S trySplit(); // // public long estimateSize(); // // public int characteristics(); // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingIterator.java // public interface ThrowingIterator<E, X extends Throwable> { // public static interface OfPrimitive<E, E_CONS, X extends Throwable> // extends ThrowingIterator<E, X> { // public void forEachRemaining(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X> { // public int nextInt() throws X; // // @Override // default public Integer next() throws X { // return nextInt(); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X> { // public long nextLong() throws X; // // @Override // default public Long next() throws X { // return nextLong(); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X> { // public double nextDouble() throws X; // // @Override // default public Double next() throws X { // return nextDouble(); // } // } // // public E next() throws X; // // public boolean hasNext() throws X; // // default public void remove() throws X { // throw new UnsupportedOperationException(); // } // // public void forEachRemaining(ThrowingConsumer<? super E, ? extends X> action) throws X; // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/intermediate/ThrowingBaseStreamIntermediate.java // public interface ThrowingBaseStreamIntermediate<S extends ThrowingBaseStreamIntermediate<S>> { // public S sequential(); // // public S parallel(); // // public S unordered(); // // public S onClose(Runnable closeHandler); // // public boolean isParallel(); // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/terminal/ThrowingBaseStreamTerminal.java // public interface ThrowingBaseStreamTerminal<T, X extends Throwable> { // public ThrowingIterator<T, X> iterator(); // // public ThrowingBaseSpliterator<T, X, ?> spliterator(); // // public void close(); // }
import java.util.function.Function; import name.falgout.jeffrey.throwing.ThrowingBaseSpliterator; import name.falgout.jeffrey.throwing.ThrowingIterator; import name.falgout.jeffrey.throwing.stream.intermediate.ThrowingBaseStreamIntermediate; import name.falgout.jeffrey.throwing.stream.terminal.ThrowingBaseStreamTerminal;
package name.falgout.jeffrey.throwing.stream; public interface ThrowingBaseStream<T, X extends Throwable, S extends ThrowingBaseStream<T, X, S>> extends ThrowingBaseStreamIntermediate<S>,
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingBaseSpliterator.java // public interface ThrowingBaseSpliterator<E, X extends Throwable, S extends ThrowingBaseSpliterator<E, X, S>> { // public static interface ThrowingSpliterator<E, X extends Throwable> // extends ThrowingBaseSpliterator<E, X, ThrowingSpliterator<E, X>> {} // // public static interface OfPrimitive<E, E_CONS, X extends Throwable, S extends OfPrimitive<E, E_CONS, X, S>> // extends ThrowingBaseSpliterator<E, X, S> { // public boolean tryAdvance(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X, OfInt<X>> { // default public boolean normalTryAdvance(IntConsumer action) throws X { // return tryAdvance((ThrowingIntConsumer<? extends X>) action::accept); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X, OfLong<X>> { // default public boolean normalTryAdvance(LongConsumer action) throws X { // return tryAdvance((ThrowingLongConsumer<? extends X>) action::accept); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X, OfDouble<X>> { // default public boolean normalTryAdvance(DoubleConsumer action) throws X { // return tryAdvance((ThrowingDoubleConsumer<? extends X>) action::accept); // } // } // // default public boolean normalTryAdvance(Consumer<? super E> action) throws X { // return tryAdvance(action::accept); // } // // public boolean tryAdvance(ThrowingConsumer<? super E, ? extends X> action) throws X; // // public S trySplit(); // // public long estimateSize(); // // public int characteristics(); // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingIterator.java // public interface ThrowingIterator<E, X extends Throwable> { // public static interface OfPrimitive<E, E_CONS, X extends Throwable> // extends ThrowingIterator<E, X> { // public void forEachRemaining(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X> { // public int nextInt() throws X; // // @Override // default public Integer next() throws X { // return nextInt(); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X> { // public long nextLong() throws X; // // @Override // default public Long next() throws X { // return nextLong(); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X> { // public double nextDouble() throws X; // // @Override // default public Double next() throws X { // return nextDouble(); // } // } // // public E next() throws X; // // public boolean hasNext() throws X; // // default public void remove() throws X { // throw new UnsupportedOperationException(); // } // // public void forEachRemaining(ThrowingConsumer<? super E, ? extends X> action) throws X; // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/intermediate/ThrowingBaseStreamIntermediate.java // public interface ThrowingBaseStreamIntermediate<S extends ThrowingBaseStreamIntermediate<S>> { // public S sequential(); // // public S parallel(); // // public S unordered(); // // public S onClose(Runnable closeHandler); // // public boolean isParallel(); // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/terminal/ThrowingBaseStreamTerminal.java // public interface ThrowingBaseStreamTerminal<T, X extends Throwable> { // public ThrowingIterator<T, X> iterator(); // // public ThrowingBaseSpliterator<T, X, ?> spliterator(); // // public void close(); // } // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/ThrowingBaseStream.java import java.util.function.Function; import name.falgout.jeffrey.throwing.ThrowingBaseSpliterator; import name.falgout.jeffrey.throwing.ThrowingIterator; import name.falgout.jeffrey.throwing.stream.intermediate.ThrowingBaseStreamIntermediate; import name.falgout.jeffrey.throwing.stream.terminal.ThrowingBaseStreamTerminal; package name.falgout.jeffrey.throwing.stream; public interface ThrowingBaseStream<T, X extends Throwable, S extends ThrowingBaseStream<T, X, S>> extends ThrowingBaseStreamIntermediate<S>,
ThrowingBaseStreamTerminal<T, X> {
JeffreyFalgout/ThrowingStream
throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/ThrowingBaseStream.java
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingBaseSpliterator.java // public interface ThrowingBaseSpliterator<E, X extends Throwable, S extends ThrowingBaseSpliterator<E, X, S>> { // public static interface ThrowingSpliterator<E, X extends Throwable> // extends ThrowingBaseSpliterator<E, X, ThrowingSpliterator<E, X>> {} // // public static interface OfPrimitive<E, E_CONS, X extends Throwable, S extends OfPrimitive<E, E_CONS, X, S>> // extends ThrowingBaseSpliterator<E, X, S> { // public boolean tryAdvance(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X, OfInt<X>> { // default public boolean normalTryAdvance(IntConsumer action) throws X { // return tryAdvance((ThrowingIntConsumer<? extends X>) action::accept); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X, OfLong<X>> { // default public boolean normalTryAdvance(LongConsumer action) throws X { // return tryAdvance((ThrowingLongConsumer<? extends X>) action::accept); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X, OfDouble<X>> { // default public boolean normalTryAdvance(DoubleConsumer action) throws X { // return tryAdvance((ThrowingDoubleConsumer<? extends X>) action::accept); // } // } // // default public boolean normalTryAdvance(Consumer<? super E> action) throws X { // return tryAdvance(action::accept); // } // // public boolean tryAdvance(ThrowingConsumer<? super E, ? extends X> action) throws X; // // public S trySplit(); // // public long estimateSize(); // // public int characteristics(); // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingIterator.java // public interface ThrowingIterator<E, X extends Throwable> { // public static interface OfPrimitive<E, E_CONS, X extends Throwable> // extends ThrowingIterator<E, X> { // public void forEachRemaining(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X> { // public int nextInt() throws X; // // @Override // default public Integer next() throws X { // return nextInt(); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X> { // public long nextLong() throws X; // // @Override // default public Long next() throws X { // return nextLong(); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X> { // public double nextDouble() throws X; // // @Override // default public Double next() throws X { // return nextDouble(); // } // } // // public E next() throws X; // // public boolean hasNext() throws X; // // default public void remove() throws X { // throw new UnsupportedOperationException(); // } // // public void forEachRemaining(ThrowingConsumer<? super E, ? extends X> action) throws X; // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/intermediate/ThrowingBaseStreamIntermediate.java // public interface ThrowingBaseStreamIntermediate<S extends ThrowingBaseStreamIntermediate<S>> { // public S sequential(); // // public S parallel(); // // public S unordered(); // // public S onClose(Runnable closeHandler); // // public boolean isParallel(); // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/terminal/ThrowingBaseStreamTerminal.java // public interface ThrowingBaseStreamTerminal<T, X extends Throwable> { // public ThrowingIterator<T, X> iterator(); // // public ThrowingBaseSpliterator<T, X, ?> spliterator(); // // public void close(); // }
import java.util.function.Function; import name.falgout.jeffrey.throwing.ThrowingBaseSpliterator; import name.falgout.jeffrey.throwing.ThrowingIterator; import name.falgout.jeffrey.throwing.stream.intermediate.ThrowingBaseStreamIntermediate; import name.falgout.jeffrey.throwing.stream.terminal.ThrowingBaseStreamTerminal;
package name.falgout.jeffrey.throwing.stream; public interface ThrowingBaseStream<T, X extends Throwable, S extends ThrowingBaseStream<T, X, S>> extends ThrowingBaseStreamIntermediate<S>, ThrowingBaseStreamTerminal<T, X> { @Override
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingBaseSpliterator.java // public interface ThrowingBaseSpliterator<E, X extends Throwable, S extends ThrowingBaseSpliterator<E, X, S>> { // public static interface ThrowingSpliterator<E, X extends Throwable> // extends ThrowingBaseSpliterator<E, X, ThrowingSpliterator<E, X>> {} // // public static interface OfPrimitive<E, E_CONS, X extends Throwable, S extends OfPrimitive<E, E_CONS, X, S>> // extends ThrowingBaseSpliterator<E, X, S> { // public boolean tryAdvance(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X, OfInt<X>> { // default public boolean normalTryAdvance(IntConsumer action) throws X { // return tryAdvance((ThrowingIntConsumer<? extends X>) action::accept); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X, OfLong<X>> { // default public boolean normalTryAdvance(LongConsumer action) throws X { // return tryAdvance((ThrowingLongConsumer<? extends X>) action::accept); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X, OfDouble<X>> { // default public boolean normalTryAdvance(DoubleConsumer action) throws X { // return tryAdvance((ThrowingDoubleConsumer<? extends X>) action::accept); // } // } // // default public boolean normalTryAdvance(Consumer<? super E> action) throws X { // return tryAdvance(action::accept); // } // // public boolean tryAdvance(ThrowingConsumer<? super E, ? extends X> action) throws X; // // public S trySplit(); // // public long estimateSize(); // // public int characteristics(); // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingIterator.java // public interface ThrowingIterator<E, X extends Throwable> { // public static interface OfPrimitive<E, E_CONS, X extends Throwable> // extends ThrowingIterator<E, X> { // public void forEachRemaining(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X> { // public int nextInt() throws X; // // @Override // default public Integer next() throws X { // return nextInt(); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X> { // public long nextLong() throws X; // // @Override // default public Long next() throws X { // return nextLong(); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X> { // public double nextDouble() throws X; // // @Override // default public Double next() throws X { // return nextDouble(); // } // } // // public E next() throws X; // // public boolean hasNext() throws X; // // default public void remove() throws X { // throw new UnsupportedOperationException(); // } // // public void forEachRemaining(ThrowingConsumer<? super E, ? extends X> action) throws X; // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/intermediate/ThrowingBaseStreamIntermediate.java // public interface ThrowingBaseStreamIntermediate<S extends ThrowingBaseStreamIntermediate<S>> { // public S sequential(); // // public S parallel(); // // public S unordered(); // // public S onClose(Runnable closeHandler); // // public boolean isParallel(); // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/terminal/ThrowingBaseStreamTerminal.java // public interface ThrowingBaseStreamTerminal<T, X extends Throwable> { // public ThrowingIterator<T, X> iterator(); // // public ThrowingBaseSpliterator<T, X, ?> spliterator(); // // public void close(); // } // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/ThrowingBaseStream.java import java.util.function.Function; import name.falgout.jeffrey.throwing.ThrowingBaseSpliterator; import name.falgout.jeffrey.throwing.ThrowingIterator; import name.falgout.jeffrey.throwing.stream.intermediate.ThrowingBaseStreamIntermediate; import name.falgout.jeffrey.throwing.stream.terminal.ThrowingBaseStreamTerminal; package name.falgout.jeffrey.throwing.stream; public interface ThrowingBaseStream<T, X extends Throwable, S extends ThrowingBaseStream<T, X, S>> extends ThrowingBaseStreamIntermediate<S>, ThrowingBaseStreamTerminal<T, X> { @Override
public ThrowingIterator<T, X> iterator();
JeffreyFalgout/ThrowingStream
throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/ThrowingBaseStream.java
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingBaseSpliterator.java // public interface ThrowingBaseSpliterator<E, X extends Throwable, S extends ThrowingBaseSpliterator<E, X, S>> { // public static interface ThrowingSpliterator<E, X extends Throwable> // extends ThrowingBaseSpliterator<E, X, ThrowingSpliterator<E, X>> {} // // public static interface OfPrimitive<E, E_CONS, X extends Throwable, S extends OfPrimitive<E, E_CONS, X, S>> // extends ThrowingBaseSpliterator<E, X, S> { // public boolean tryAdvance(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X, OfInt<X>> { // default public boolean normalTryAdvance(IntConsumer action) throws X { // return tryAdvance((ThrowingIntConsumer<? extends X>) action::accept); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X, OfLong<X>> { // default public boolean normalTryAdvance(LongConsumer action) throws X { // return tryAdvance((ThrowingLongConsumer<? extends X>) action::accept); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X, OfDouble<X>> { // default public boolean normalTryAdvance(DoubleConsumer action) throws X { // return tryAdvance((ThrowingDoubleConsumer<? extends X>) action::accept); // } // } // // default public boolean normalTryAdvance(Consumer<? super E> action) throws X { // return tryAdvance(action::accept); // } // // public boolean tryAdvance(ThrowingConsumer<? super E, ? extends X> action) throws X; // // public S trySplit(); // // public long estimateSize(); // // public int characteristics(); // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingIterator.java // public interface ThrowingIterator<E, X extends Throwable> { // public static interface OfPrimitive<E, E_CONS, X extends Throwable> // extends ThrowingIterator<E, X> { // public void forEachRemaining(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X> { // public int nextInt() throws X; // // @Override // default public Integer next() throws X { // return nextInt(); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X> { // public long nextLong() throws X; // // @Override // default public Long next() throws X { // return nextLong(); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X> { // public double nextDouble() throws X; // // @Override // default public Double next() throws X { // return nextDouble(); // } // } // // public E next() throws X; // // public boolean hasNext() throws X; // // default public void remove() throws X { // throw new UnsupportedOperationException(); // } // // public void forEachRemaining(ThrowingConsumer<? super E, ? extends X> action) throws X; // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/intermediate/ThrowingBaseStreamIntermediate.java // public interface ThrowingBaseStreamIntermediate<S extends ThrowingBaseStreamIntermediate<S>> { // public S sequential(); // // public S parallel(); // // public S unordered(); // // public S onClose(Runnable closeHandler); // // public boolean isParallel(); // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/terminal/ThrowingBaseStreamTerminal.java // public interface ThrowingBaseStreamTerminal<T, X extends Throwable> { // public ThrowingIterator<T, X> iterator(); // // public ThrowingBaseSpliterator<T, X, ?> spliterator(); // // public void close(); // }
import java.util.function.Function; import name.falgout.jeffrey.throwing.ThrowingBaseSpliterator; import name.falgout.jeffrey.throwing.ThrowingIterator; import name.falgout.jeffrey.throwing.stream.intermediate.ThrowingBaseStreamIntermediate; import name.falgout.jeffrey.throwing.stream.terminal.ThrowingBaseStreamTerminal;
package name.falgout.jeffrey.throwing.stream; public interface ThrowingBaseStream<T, X extends Throwable, S extends ThrowingBaseStream<T, X, S>> extends ThrowingBaseStreamIntermediate<S>, ThrowingBaseStreamTerminal<T, X> { @Override public ThrowingIterator<T, X> iterator(); @Override
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingBaseSpliterator.java // public interface ThrowingBaseSpliterator<E, X extends Throwable, S extends ThrowingBaseSpliterator<E, X, S>> { // public static interface ThrowingSpliterator<E, X extends Throwable> // extends ThrowingBaseSpliterator<E, X, ThrowingSpliterator<E, X>> {} // // public static interface OfPrimitive<E, E_CONS, X extends Throwable, S extends OfPrimitive<E, E_CONS, X, S>> // extends ThrowingBaseSpliterator<E, X, S> { // public boolean tryAdvance(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X, OfInt<X>> { // default public boolean normalTryAdvance(IntConsumer action) throws X { // return tryAdvance((ThrowingIntConsumer<? extends X>) action::accept); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X, OfLong<X>> { // default public boolean normalTryAdvance(LongConsumer action) throws X { // return tryAdvance((ThrowingLongConsumer<? extends X>) action::accept); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X, OfDouble<X>> { // default public boolean normalTryAdvance(DoubleConsumer action) throws X { // return tryAdvance((ThrowingDoubleConsumer<? extends X>) action::accept); // } // } // // default public boolean normalTryAdvance(Consumer<? super E> action) throws X { // return tryAdvance(action::accept); // } // // public boolean tryAdvance(ThrowingConsumer<? super E, ? extends X> action) throws X; // // public S trySplit(); // // public long estimateSize(); // // public int characteristics(); // } // // Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingIterator.java // public interface ThrowingIterator<E, X extends Throwable> { // public static interface OfPrimitive<E, E_CONS, X extends Throwable> // extends ThrowingIterator<E, X> { // public void forEachRemaining(E_CONS action) throws X; // } // // public static interface OfInt<X extends Throwable> // extends OfPrimitive<Integer, ThrowingIntConsumer<? extends X>, X> { // public int nextInt() throws X; // // @Override // default public Integer next() throws X { // return nextInt(); // } // } // // public static interface OfLong<X extends Throwable> // extends OfPrimitive<Long, ThrowingLongConsumer<? extends X>, X> { // public long nextLong() throws X; // // @Override // default public Long next() throws X { // return nextLong(); // } // } // // public static interface OfDouble<X extends Throwable> // extends OfPrimitive<Double, ThrowingDoubleConsumer<? extends X>, X> { // public double nextDouble() throws X; // // @Override // default public Double next() throws X { // return nextDouble(); // } // } // // public E next() throws X; // // public boolean hasNext() throws X; // // default public void remove() throws X { // throw new UnsupportedOperationException(); // } // // public void forEachRemaining(ThrowingConsumer<? super E, ? extends X> action) throws X; // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/intermediate/ThrowingBaseStreamIntermediate.java // public interface ThrowingBaseStreamIntermediate<S extends ThrowingBaseStreamIntermediate<S>> { // public S sequential(); // // public S parallel(); // // public S unordered(); // // public S onClose(Runnable closeHandler); // // public boolean isParallel(); // } // // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/terminal/ThrowingBaseStreamTerminal.java // public interface ThrowingBaseStreamTerminal<T, X extends Throwable> { // public ThrowingIterator<T, X> iterator(); // // public ThrowingBaseSpliterator<T, X, ?> spliterator(); // // public void close(); // } // Path: throwing-stream/src/main/java/name/falgout/jeffrey/throwing/stream/ThrowingBaseStream.java import java.util.function.Function; import name.falgout.jeffrey.throwing.ThrowingBaseSpliterator; import name.falgout.jeffrey.throwing.ThrowingIterator; import name.falgout.jeffrey.throwing.stream.intermediate.ThrowingBaseStreamIntermediate; import name.falgout.jeffrey.throwing.stream.terminal.ThrowingBaseStreamTerminal; package name.falgout.jeffrey.throwing.stream; public interface ThrowingBaseStream<T, X extends Throwable, S extends ThrowingBaseStream<T, X, S>> extends ThrowingBaseStreamIntermediate<S>, ThrowingBaseStreamTerminal<T, X> { @Override public ThrowingIterator<T, X> iterator(); @Override
public ThrowingBaseSpliterator<T, X, ?> spliterator();
DevOps-TangoMe/BucketSyncer
src/main/java/com/tango/BucketSyncer/KeyListers/KeyLister.java
// Path: src/main/java/com/tango/BucketSyncer/MirrorContext.java // @AllArgsConstructor // public class MirrorContext { // // @Getter // @Setter // private MirrorOptions options; // @Getter // private final MirrorStats stats = new MirrorStats(); // // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // }
import com.tango.BucketSyncer.MirrorContext; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean;
/** * Copyright 2013 Jonathan Cobb * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyListers; @Slf4j public abstract class KeyLister implements Runnable {
// Path: src/main/java/com/tango/BucketSyncer/MirrorContext.java // @AllArgsConstructor // public class MirrorContext { // // @Getter // @Setter // private MirrorOptions options; // @Getter // private final MirrorStats stats = new MirrorStats(); // // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // } // Path: src/main/java/com/tango/BucketSyncer/KeyListers/KeyLister.java import com.tango.BucketSyncer.MirrorContext; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; /** * Copyright 2013 Jonathan Cobb * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyListers; @Slf4j public abstract class KeyLister implements Runnable {
protected MirrorContext context;
DevOps-TangoMe/BucketSyncer
src/main/java/com/tango/BucketSyncer/KeyListers/KeyLister.java
// Path: src/main/java/com/tango/BucketSyncer/MirrorContext.java // @AllArgsConstructor // public class MirrorContext { // // @Getter // @Setter // private MirrorOptions options; // @Getter // private final MirrorStats stats = new MirrorStats(); // // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // }
import com.tango.BucketSyncer.MirrorContext; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean;
/** * Copyright 2013 Jonathan Cobb * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyListers; @Slf4j public abstract class KeyLister implements Runnable { protected MirrorContext context; protected Integer maxQueueCapacity; protected String bucket; protected String prefix; protected final AtomicBoolean done = new AtomicBoolean(false); public boolean isDone() { return done.get(); } public KeyLister(String bucket, String prefix, MirrorContext context, Integer maxQueueCapacity) { this.bucket = bucket; this.prefix = prefix; this.context = context; this.maxQueueCapacity = maxQueueCapacity; }
// Path: src/main/java/com/tango/BucketSyncer/MirrorContext.java // @AllArgsConstructor // public class MirrorContext { // // @Getter // @Setter // private MirrorOptions options; // @Getter // private final MirrorStats stats = new MirrorStats(); // // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // } // Path: src/main/java/com/tango/BucketSyncer/KeyListers/KeyLister.java import com.tango.BucketSyncer.MirrorContext; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; /** * Copyright 2013 Jonathan Cobb * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyListers; @Slf4j public abstract class KeyLister implements Runnable { protected MirrorContext context; protected Integer maxQueueCapacity; protected String bucket; protected String prefix; protected final AtomicBoolean done = new AtomicBoolean(false); public boolean isDone() { return done.get(); } public KeyLister(String bucket, String prefix, MirrorContext context, Integer maxQueueCapacity) { this.bucket = bucket; this.prefix = prefix; this.context = context; this.maxQueueCapacity = maxQueueCapacity; }
public abstract List<ObjectSummary> getNextBatch();
DevOps-TangoMe/BucketSyncer
src/main/java/com/tango/BucketSyncer/KeyJobs/S32S3KeyCopyJob.java
// Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // }
import com.amazonaws.services.s3.model.*; import com.tango.BucketSyncer.*; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpStatus; import java.util.Date;
/** * Copyright 2013 Jonathan Cobb * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyJobs; /** * Handles a single key. Determines if it should be copied, and if so, performs the copy operation. */ @Slf4j public class S32S3KeyCopyJob extends S32S3KeyJob { protected String keydest; public S32S3KeyCopyJob(Object sourceClient, Object destClient, MirrorContext context,
// Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // } // Path: src/main/java/com/tango/BucketSyncer/KeyJobs/S32S3KeyCopyJob.java import com.amazonaws.services.s3.model.*; import com.tango.BucketSyncer.*; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpStatus; import java.util.Date; /** * Copyright 2013 Jonathan Cobb * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyJobs; /** * Handles a single key. Determines if it should be copied, and if so, performs the copy operation. */ @Slf4j public class S32S3KeyCopyJob extends S32S3KeyJob { protected String keydest; public S32S3KeyCopyJob(Object sourceClient, Object destClient, MirrorContext context,
ObjectSummary summary,
DevOps-TangoMe/BucketSyncer
src/main/java/com/tango/BucketSyncer/KeyJobs/KeyJob.java
// Path: src/main/java/com/tango/BucketSyncer/MirrorContext.java // @AllArgsConstructor // public class MirrorContext { // // @Getter // @Setter // private MirrorOptions options; // @Getter // private final MirrorStats stats = new MirrorStats(); // // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // }
import com.tango.BucketSyncer.MirrorContext; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary;
/** * Copyright 2013 Jonathan Cobb * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyJobs; public abstract class KeyJob implements Runnable { protected final ObjectSummary summary; protected final Object notifyLock;
// Path: src/main/java/com/tango/BucketSyncer/MirrorContext.java // @AllArgsConstructor // public class MirrorContext { // // @Getter // @Setter // private MirrorOptions options; // @Getter // private final MirrorStats stats = new MirrorStats(); // // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // } // Path: src/main/java/com/tango/BucketSyncer/KeyJobs/KeyJob.java import com.tango.BucketSyncer.MirrorContext; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; /** * Copyright 2013 Jonathan Cobb * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyJobs; public abstract class KeyJob implements Runnable { protected final ObjectSummary summary; protected final Object notifyLock;
protected final MirrorContext context;
DevOps-TangoMe/BucketSyncer
src/main/java/com/tango/BucketSyncer/KeyListers/GCSKeyLister.java
// Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/GCS_ObjectSummary.java // public class GCS_ObjectSummary implements ObjectSummary { // StorageObject storageObject; // // public GCS_ObjectSummary(StorageObject storageObject) { // this.storageObject = storageObject; // } // // @Override // public String getKey() { // return storageObject.getName(); // } // // @Override // public long getSize() { // return storageObject.getSize().longValue(); // } // // @Override // public Date getLastModified() { // return new Date(storageObject.getUpdated().getValue()); // } // // @Override // public String getETag() { // return storageObject.getEtag(); // } // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // }
import com.google.api.services.storage.Storage; import com.google.api.services.storage.model.Objects; import com.google.api.services.storage.model.StorageObject; import com.tango.BucketSyncer.*; import com.tango.BucketSyncer.ObjectSummaries.GCS_ObjectSummary; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.ArrayList; import java.util.List;
/** * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyListers; @Slf4j public class GCSKeyLister extends KeyLister { private Storage gcsClient;
// Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/GCS_ObjectSummary.java // public class GCS_ObjectSummary implements ObjectSummary { // StorageObject storageObject; // // public GCS_ObjectSummary(StorageObject storageObject) { // this.storageObject = storageObject; // } // // @Override // public String getKey() { // return storageObject.getName(); // } // // @Override // public long getSize() { // return storageObject.getSize().longValue(); // } // // @Override // public Date getLastModified() { // return new Date(storageObject.getUpdated().getValue()); // } // // @Override // public String getETag() { // return storageObject.getEtag(); // } // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // } // Path: src/main/java/com/tango/BucketSyncer/KeyListers/GCSKeyLister.java import com.google.api.services.storage.Storage; import com.google.api.services.storage.model.Objects; import com.google.api.services.storage.model.StorageObject; import com.tango.BucketSyncer.*; import com.tango.BucketSyncer.ObjectSummaries.GCS_ObjectSummary; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyListers; @Slf4j public class GCSKeyLister extends KeyLister { private Storage gcsClient;
private final List<ObjectSummary> summaries;
DevOps-TangoMe/BucketSyncer
src/main/java/com/tango/BucketSyncer/KeyListers/GCSKeyLister.java
// Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/GCS_ObjectSummary.java // public class GCS_ObjectSummary implements ObjectSummary { // StorageObject storageObject; // // public GCS_ObjectSummary(StorageObject storageObject) { // this.storageObject = storageObject; // } // // @Override // public String getKey() { // return storageObject.getName(); // } // // @Override // public long getSize() { // return storageObject.getSize().longValue(); // } // // @Override // public Date getLastModified() { // return new Date(storageObject.getUpdated().getValue()); // } // // @Override // public String getETag() { // return storageObject.getEtag(); // } // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // }
import com.google.api.services.storage.Storage; import com.google.api.services.storage.model.Objects; import com.google.api.services.storage.model.StorageObject; import com.tango.BucketSyncer.*; import com.tango.BucketSyncer.ObjectSummaries.GCS_ObjectSummary; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.ArrayList; import java.util.List;
/** * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyListers; @Slf4j public class GCSKeyLister extends KeyLister { private Storage gcsClient; private final List<ObjectSummary> summaries; private Objects objects; public GCSKeyLister(Object client, String bucket, String prefix, MirrorContext context, Integer maxQueueCapacity) { super(bucket, prefix, context, maxQueueCapacity); this.gcsClient = (Storage) client; final MirrorOptions options = context.getOptions(); int fetchSize = options.getMaxThreads(); this.summaries = new ArrayList<ObjectSummary>(10 * fetchSize); objects = gcsGetFirstBatch(bucket, prefix, Long.valueOf(fetchSize)); synchronized (summaries) { for (StorageObject object : objects.getItems()) { // Add to object summaries
// Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/GCS_ObjectSummary.java // public class GCS_ObjectSummary implements ObjectSummary { // StorageObject storageObject; // // public GCS_ObjectSummary(StorageObject storageObject) { // this.storageObject = storageObject; // } // // @Override // public String getKey() { // return storageObject.getName(); // } // // @Override // public long getSize() { // return storageObject.getSize().longValue(); // } // // @Override // public Date getLastModified() { // return new Date(storageObject.getUpdated().getValue()); // } // // @Override // public String getETag() { // return storageObject.getEtag(); // } // } // // Path: src/main/java/com/tango/BucketSyncer/ObjectSummaries/ObjectSummary.java // public interface ObjectSummary { // public String getKey(); // // public long getSize(); // // public Date getLastModified(); // // public String getETag(); // } // Path: src/main/java/com/tango/BucketSyncer/KeyListers/GCSKeyLister.java import com.google.api.services.storage.Storage; import com.google.api.services.storage.model.Objects; import com.google.api.services.storage.model.StorageObject; import com.tango.BucketSyncer.*; import com.tango.BucketSyncer.ObjectSummaries.GCS_ObjectSummary; import com.tango.BucketSyncer.ObjectSummaries.ObjectSummary; import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * Copyright 2014 TangoMe Inc. * * 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.tango.BucketSyncer.KeyListers; @Slf4j public class GCSKeyLister extends KeyLister { private Storage gcsClient; private final List<ObjectSummary> summaries; private Objects objects; public GCSKeyLister(Object client, String bucket, String prefix, MirrorContext context, Integer maxQueueCapacity) { super(bucket, prefix, context, maxQueueCapacity); this.gcsClient = (Storage) client; final MirrorOptions options = context.getOptions(); int fetchSize = options.getMaxThreads(); this.summaries = new ArrayList<ObjectSummary>(10 * fetchSize); objects = gcsGetFirstBatch(bucket, prefix, Long.valueOf(fetchSize)); synchronized (summaries) { for (StorageObject object : objects.getItems()) { // Add to object summaries
ObjectSummary os = new GCS_ObjectSummary(object);