Package org.jboss.as.ejb3.component.entity.entitycache

Examples of org.jboss.as.ejb3.component.entity.entitycache.TransactionLocalEntityCache$CacheEntry


        every31st9_30_15_AM.dayOfMonth(31);
        every31st9_30_15_AM.hour(9);
        every31st9_30_15_AM.minute("30");
        every31st9_30_15_AM.second(15);

        CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(every31st9_30_15_AM);

        Calendar firstTimeout = calendarTimeout.getFirstTimeout();
        Assert.assertNotNull("first timeout is null", firstTimeout);
        Date firstTimeoutDate = firstTimeout.getTime();
        int minute = firstTimeout.get(Calendar.MINUTE);
        int second = firstTimeout.get(Calendar.SECOND);
        int hour = firstTimeout.get(Calendar.HOUR_OF_DAY);
        int amOrPm = firstTimeout.get(Calendar.AM_PM);
        int dayOfMonth = firstTimeout.get(Calendar.DAY_OF_MONTH);
        Assert.assertEquals("Unexpected second in first timeout " + firstTimeoutDate, 15, second);
        Assert.assertEquals("Unexpected minute in first timeout " + firstTimeoutDate, 30, minute);
        Assert.assertEquals("Unexpected hour in first timeout " + firstTimeoutDate, 9, hour);
        Assert.assertEquals("Unexpected AM/PM in first timeout ", Calendar.AM, amOrPm);
        Assert.assertEquals("Unexpected day of month in first timeout ", 31, dayOfMonth);

        Calendar previousTimeout = firstTimeout;
        for (int i = 1; i <= 180; i++) {
            Calendar nextTimeout = calendarTimeout.getNextTimeout(previousTimeout);

            Assert.assertNotNull("Next timeout is null", nextTimeout);
            Assert.assertNotNull("Next timeout is *before* the current time", nextTimeout.after(previousTimeout));

            Date nextTimeoutDate = nextTimeout.getTime();
View Full Code Here


    public void testRun29thOfFeb() {
        ScheduleExpression everyLeapYearOn29thFeb = this.getTimezoneSpecificScheduleExpression();
        everyLeapYearOn29thFeb.dayOfMonth(29);
        everyLeapYearOn29thFeb.month("fEb");

        CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(everyLeapYearOn29thFeb);

        Calendar firstTimeout = calendarTimeout.getFirstTimeout();
        Assert.assertNotNull("first timeout is null", firstTimeout);
        Date firstTimeoutDate = firstTimeout.getTime();
        int minute = firstTimeout.get(Calendar.MINUTE);
        int second = firstTimeout.get(Calendar.SECOND);
        int hour = firstTimeout.get(Calendar.HOUR_OF_DAY);
        int amOrPm = firstTimeout.get(Calendar.AM_PM);
        int dayOfMonth = firstTimeout.get(Calendar.DAY_OF_MONTH);
        int year = firstTimeout.get(Calendar.YEAR);
        int month = firstTimeout.get(Calendar.MONTH);

        Assert.assertEquals("Unexpected second in first timeout " + firstTimeoutDate, 0, second);
        Assert.assertEquals("Unexpected minute in first timeout " + firstTimeoutDate, 0, minute);
        Assert.assertEquals("Unexpected hour in first timeout " + firstTimeout, 0, hour);
        Assert.assertEquals("Unexpected AM/PM in first timeout ", Calendar.AM, amOrPm);
        Assert.assertEquals("Unexpected day of month in first timeout ", 29, dayOfMonth);
        Assert.assertEquals("Unexpected month in first timeout ", Calendar.FEBRUARY, month);
        Assert.assertTrue("Year: " + year + " is not a leap year", this.isLeapYear(firstTimeout));

        Calendar previousTimeout = firstTimeout;
        for (int i = 1; i <= 2; i++) {
            Calendar nextTimeout = calendarTimeout.getNextTimeout(previousTimeout);

            Assert.assertNotNull("Next timeout is null", nextTimeout);
            Assert.assertNotNull("Next timeout is *before* the current time", nextTimeout.after(previousTimeout));

            Date nextTimeoutDate = nextTimeout.getTime();
View Full Code Here

        every0_15_30_Sec_At_9_30_PM.month("Nov-Feb");
        every0_15_30_Sec_At_9_30_PM.second("0,15,30");
        every0_15_30_Sec_At_9_30_PM.minute(30);
        every0_15_30_Sec_At_9_30_PM.hour("21");

        CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(every0_15_30_Sec_At_9_30_PM);
        Calendar firstTimeout = calendarTimeout.getFirstTimeout();
        Assert.assertNotNull("first timeout is null", firstTimeout);
        Date firstTimeoutDate = firstTimeout.getTime();
        logger.debug("First timeout is " + firstTimeoutDate);

        int minute = firstTimeout.get(Calendar.MINUTE);
        int second = firstTimeout.get(Calendar.SECOND);
        int hour = firstTimeout.get(Calendar.HOUR_OF_DAY);
        int amOrPm = firstTimeout.get(Calendar.AM_PM);
        int dayOfMonth = firstTimeout.get(Calendar.DAY_OF_MONTH);
        int month = firstTimeout.get(Calendar.MONTH);

        Assert.assertEquals("Unexpected second in first timeout " + firstTimeoutDate, 0, second);
        Assert.assertEquals("Unexpected minute in first timeout " + firstTimeoutDate, 30, minute);
        Assert.assertEquals("Unexpected hour in first timeout " + firstTimeoutDate, 21, hour);
        Assert.assertEquals("Unexpected AM/PM in first timeout ", Calendar.PM, amOrPm);
        Assert.assertEquals("Unexpected day of month in first timeout ", 31, dayOfMonth);
        List<Integer> validMonths = new ArrayList<Integer>();
        validMonths.add(Calendar.NOVEMBER);
        validMonths.add(Calendar.DECEMBER);
        validMonths.add(Calendar.JANUARY);
        validMonths.add(Calendar.FEBRUARY);
        Assert.assertTrue("Unexpected month: " + month, validMonths.contains(month));

        Calendar nextTimeout = calendarTimeout.getNextTimeout(firstTimeout);
        long diff = nextTimeout.getTimeInMillis() - firstTimeout.getTimeInMillis();
        Assert.assertEquals("Unexpected next timeout " + nextTimeout.getTime(), 15 * 1000, diff);

        Calendar currentSystemDate = new GregorianCalendar();
        Calendar nextTimeoutFromNow = calendarTimeout.getNextTimeout(currentSystemDate);
        logger.debug("Next timeout from now is " + nextTimeoutFromNow.getTime());
        int nextMinute = nextTimeoutFromNow.get(Calendar.MINUTE);
        int nextSecond = nextTimeoutFromNow.get(Calendar.SECOND);
        int nextHour = nextTimeoutFromNow.get(Calendar.HOUR_OF_DAY);
        int nextAmOrPM = nextTimeoutFromNow.get(Calendar.AM_PM);
View Full Code Here

        ScheduleExpression every10Secs = this.getTimezoneSpecificScheduleExpression();
        every10Secs.second("*/10");
        every10Secs.minute("*");
        every10Secs.hour("*");

        CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(every10Secs);
        Calendar firstTimeout = calendarTimeout.getFirstTimeout();

        int firstTimeoutSecond = firstTimeout.get(Calendar.SECOND);
        Assert.assertTrue("Unexpected second " + firstTimeoutSecond + " in first timeout " + firstTimeout,
                firstTimeoutSecond % 10 == 0);

        Calendar previousTimeout = firstTimeout;
        for (int i = 0; i < 5; i++) {
            Calendar nextTimeout = calendarTimeout.getNextTimeout(previousTimeout);
            int nextTimeoutSecond = nextTimeout.get(Calendar.SECOND);
            Assert.assertTrue("Unexpected second " + nextTimeoutSecond + " in next timeout " + nextTimeout,
                    nextTimeoutSecond % 10 == 0);

            previousTimeout = nextTimeout;
View Full Code Here

        for (String invalidRange : invalidRangeValues) {
            boolean accepts = RangeValue.accepts(invalidRange);
            Assert.assertFalse("Range value accepted an invalid value: " + invalidRange, accepts);

            try {
                RangeValue invalidRangeValue = new RangeValue(invalidRange);
                Assert.fail("Range value did *not* throw IllegalArgumentException for an invalid range: " + invalidRange);
            } catch (IllegalArgumentException iae) {
                // expected
            }
        }
View Full Code Here

        String[] validRanges =
                {"1-8", "-7--1", "7--1", "1st Fri-1st Mon"};
        for (String validRange : validRanges) {
            boolean accepts = RangeValue.accepts(validRange);
            Assert.assertTrue("Valid range value wasn't accepted: " + validRange, accepts);
            RangeValue validRangeValue = new RangeValue(validRange);
        }
    }
View Full Code Here

        if (exceptionClassName == null || exceptionClassName.isEmpty()) {
            throw EjbMessages.MESSAGES.stringParamCannotBeNullOrEmpty("Exception class name");
        }
        //TODO: Is this a good idea? ApplicationException's equals/hashCode
        //will not work the way that would be expected
        ApplicationExceptionDetails appException = new ApplicationExceptionDetails(exceptionClassName, inherited, rollback);
        // add it to the map
        this.applicationExceptions.put(exceptionClassName, appException);
    }
View Full Code Here

*/
public class LeastRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry lruCacheEntry = null;
        for (Object o : cache.getAll()) {
            CacheEntry cacheEntry = (CacheEntry) o;
            if (lruCacheEntry == null) {
                lruCacheEntry = cacheEntry;
            } else if (lruCacheEntry.getLastAccessed() > cacheEntry.getLastAccessed()) {
                lruCacheEntry = cacheEntry;
            }
        }
        if (lruCacheEntry != null) {
            cache.evict(lruCacheEntry.getKey());
View Full Code Here

*/
public class MostRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry mruCacheEntry = null;
        for (Object o : cache.getAll()) {
            CacheEntry cacheEntry = (CacheEntry) o;
            if (mruCacheEntry == null) {
                mruCacheEntry = cacheEntry;
            } else if (mruCacheEntry.getLastAccessed() < cacheEntry.getLastAccessed()) {
                mruCacheEntry = cacheEntry;
            }
        }
        if (mruCacheEntry != null) {
            cache.evict(mruCacheEntry.getKey());
View Full Code Here

public class RandomEvictionAlgorithm implements EvictionAlgorithm {
    private static Random random = new Random();

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry lruCacheEntry = null;
        Collection all = cache.getAll();
        int evictionIndex = random.nextInt(all.size());
        int index = 0;

        for (Object anAll : all) {
            CacheEntry cacheEntry = (CacheEntry) anAll;
            if (index == evictionIndex) {
                lruCacheEntry = cacheEntry;
                break;
            }
            index++;
View Full Code Here

TOP

Related Classes of org.jboss.as.ejb3.component.entity.entitycache.TransactionLocalEntityCache$CacheEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.