/** * Find the key of the first non-serializable value in the given Map. * * @return The key of the first non-serializable value in the given Map or * null if all values are serializable. */ protected Object getKeyOfNonSerializableValue(Map<?, ?> data) { for (Iterator<?> entryIter = data.entrySet().iterator(); entryIter.hasNext();) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>)entryIter.next(); ByteArrayOutputStream baos = null; try { baos = serializeObject(entry.getValue()); } catch (IOException e) { return entry.getKey(); } finally { if (baos != null) { try { baos.close(); } catch (IOException ignore) {} } } } // As long as it is true that the Map was not serializable, we should // not hit this case. return null; }
/** * Find the key of the first non-serializable value in the given Map. * * @return The key of the first non-serializable value in the given Map or * null if all values are serializable. */ protected Object getKeyOfNonSerializableValue(Map<?, ?> data) { for (Iterator<?> entryIter = data.entrySet().iterator(); entryIter.hasNext();) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>)entryIter.next(); ByteArrayOutputStream baos = null; try { baos = serializeObject(entry.getValue()); } catch (IOException e) { return entry.getKey(); } finally { if (baos != null) { try { baos.close(); } catch (IOException ignore) {} } } } // As long as it is true that the Map was not serializable, we should // not hit this case. return null; }
/** * <p> * Insert a new calendar. * </p> * * @param conn * the DB Connection * @param calendarName * the name for the new calendar * @param calendar * the calendar * @return the number of rows inserted * @throws IOException * if there were problems serializing the calendar */ public int insertCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; try { ps = conn.prepareStatement(rtp(INSERT_CALENDAR)); ps.setString(1, calendarName); setBytes(ps, 2, baos); return ps.executeUpdate(); } finally { closeStatement(ps); } }
/** * <p> * Insert a new calendar. * </p> * * @param conn * the DB Connection * @param calendarName * the name for the new calendar * @param calendar * the calendar * @return the number of rows inserted * @throws IOException * if there were problems serializing the calendar */ public int insertCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; try { ps = conn.prepareStatement(rtp(INSERT_CALENDAR)); ps.setString(1, calendarName); setBytes(ps, 2, baos); return ps.executeUpdate(); } finally { closeStatement(ps); } }
/** * <p> * Update a calendar. * </p> * * @param conn * the DB Connection * @param calendarName * the name for the new calendar * @param calendar * the calendar * @return the number of rows updated * @throws IOException * if there were problems serializing the calendar */ public int updateCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; try { ps = conn.prepareStatement(rtp(UPDATE_CALENDAR)); setBytes(ps, 1, baos); ps.setString(2, calendarName); return ps.executeUpdate(); } finally { closeStatement(ps); } }
/** * <p> * Update a calendar. * </p> * * @param conn * the DB Connection * @param calendarName * the name for the new calendar * @param calendar * the calendar * @return the number of rows updated * @throws IOException * if there were problems serializing the calendar */ public int updateCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; try { ps = conn.prepareStatement(rtp(UPDATE_CALENDAR)); setBytes(ps, 1, baos); ps.setString(2, calendarName); return ps.executeUpdate(); } finally { closeStatement(ps); } }
/** * <p> * Remove the transient data from and then create a serialized <code>java.util.ByteArrayOutputStream</code> * version of a <code>{@link org.quartz.JobDataMap}</code>. * </p> * * @param data * the JobDataMap to serialize * @return the serialized ByteArrayOutputStream * @throws IOException * if serialization causes an error */ protected ByteArrayOutputStream serializeJobData(JobDataMap data) throws IOException { if (canUseProperties()) { return serializeProperties(data); } try { return serializeObject(data); } catch (NotSerializableException e) { throw new NotSerializableException( "Unable to serialize JobDataMap for insertion into " + "database because the value of property '" + getKeyOfNonSerializableValue(data) + "' is not serializable: " + e.getMessage()); } }
/** * <p> * Remove the transient data from and then create a serialized <code>java.util.ByteArrayOutputStream</code> * version of a <code>{@link org.quartz.JobDataMap}</code>. * </p> * * @param data * the JobDataMap to serialize * @return the serialized ByteArrayOutputStream * @throws IOException * if serialization causes an error */ protected ByteArrayOutputStream serializeJobData(JobDataMap data) throws IOException { if (canUseProperties()) { return serializeProperties(data); } try { return serializeObject(data); } catch (NotSerializableException e) { throw new NotSerializableException( "Unable to serialize JobDataMap for insertion into " + "database because the value of property '" + getKeyOfNonSerializableValue(data) + "' is not serializable: " + e.getMessage()); } }
/** * Find the key of the first non-serializable value in the given Map. * * @return The key of the first non-serializable value in the given Map or * null if all values are serializable. */ protected Object getKeyOfNonSerializableValue(Map data) { for (Iterator entryIter = data.entrySet().iterator(); entryIter.hasNext();) { Map.Entry entry = (Map.Entry)entryIter.next(); ByteArrayOutputStream baos = null; try { serializeObject(entry.getValue()); } catch (IOException e) { return entry.getKey(); } finally { if (baos != null) { try { baos.close(); } catch (IOException ignore) {} } } } // As long as it is true that the Map was not serializable, we should // not hit this case. return null; }
/** * Find the key of the first non-serializable value in the given Map. * * @return The key of the first non-serializable value in the given Map or * null if all values are serializable. */ protected Object getKeyOfNonSerializableValue(Map data) { for (Iterator entryIter = data.entrySet().iterator(); entryIter.hasNext();) { Map.Entry entry = (Map.Entry)entryIter.next(); ByteArrayOutputStream baos = null; try { baos = serializeObject(entry.getValue()); } catch (IOException e) { return entry.getKey(); } finally { if (baos != null) { try { baos.close(); } catch (IOException ignore) {} } } } // As long as it is true that the Map was not serializable, we should // not hit this case. return null; }
/** * <p> * Insert a new calendar. * </p> * * @param conn * the DB Connection * @param calendarName * the name for the new calendar * @param calendar * the calendar * @return the number of rows inserted * @throws IOException * if there were problems serializing the calendar */ public int insertCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; try { ps = conn.prepareStatement(rtp(INSERT_CALENDAR)); ps.setString(1, calendarName); setBytes(ps, 2, baos); return ps.executeUpdate(); } finally { closeStatement(ps); } }
/** * <p> * Update a calendar. * </p> * * @param conn * the DB Connection * @param calendarName * the name for the new calendar * @param calendar * the calendar * @return the number of rows updated * @throws IOException * if there were problems serializing the calendar */ public int updateCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; try { ps = conn.prepareStatement(rtp(UPDATE_CALENDAR)); setBytes(ps, 1, baos); ps.setString(2, calendarName); return ps.executeUpdate(); } finally { closeStatement(ps); } }
/** * <p> * Insert a new calendar. * </p> * * @param conn * the DB Connection * @param calendarName * the name for the new calendar * @param calendar * the calendar * @return the number of rows inserted * @throws IOException * if there were problems serializing the calendar */ public int insertCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; try { ps = conn.prepareStatement(rtp(INSERT_CALENDAR)); ps.setString(1, calendarName); setBytes(ps, 2, baos); return ps.executeUpdate(); } finally { closeStatement(ps); } }
/** * <p> * Update a calendar. * </p> * * @param conn * the DB Connection * @param calendarName * the name for the new calendar * @param calendar * the calendar * @return the number of rows updated * @throws IOException * if there were problems serializing the calendar */ public int updateCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; try { ps = conn.prepareStatement(rtp(UPDATE_CALENDAR)); setBytes(ps, 1, baos); ps.setString(2, calendarName); return ps.executeUpdate(); } finally { closeStatement(ps); } }
/** * <p> * Remove the transient data from and then create a serialized <code>java.util.ByteArrayOutputStream</code> * version of a <code>{@link org.quartz.JobDataMap}</code>. * </p> * * @param data * the JobDataMap to serialize * @return the serialized ByteArrayOutputStream * @throws IOException * if serialization causes an error */ protected ByteArrayOutputStream serializeJobData(JobDataMap data) throws IOException { if (canUseProperties()) { return serializeProperties(data); } try { return serializeObject(data); } catch (NotSerializableException e) { throw new NotSerializableException( "Unable to serialize JobDataMap for insertion into " + "database because the value of property '" + getKeyOfNonSerializableValue(data) + "' is not serializable: " + e.getMessage()); } }
/** * <p> * Remove the transient data from and then create a serialized <code>java.util.ByteArrayOutputStream</code> * version of a <code>{@link org.quartz.JobDataMap}</code>. * </p> * * @param data * the JobDataMap to serialize * @return the serialized ByteArrayOutputStream * @throws IOException * if serialization causes an error */ protected ByteArrayOutputStream serializeJobData(JobDataMap data) throws IOException { if (canUseProperties()) { return serializeProperties(data); } try { return serializeObject(data); } catch (NotSerializableException e) { throw new NotSerializableException( "Unable to serialize JobDataMap for insertion into " + "database because the value of property '" + getKeyOfNonSerializableValue(data) + "' is not serializable: " + e.getMessage()); } }