Skip to content

Commit

Permalink
2 level deep methods don't get intercepted
Browse files Browse the repository at this point in the history
  • Loading branch information
alesj committed Apr 7, 2011
1 parent 0bb915c commit 57a5031
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 2 deletions.
Expand Up @@ -25,7 +25,7 @@
/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public class Client extends Entity
public class Client extends Timestamped
{
String name;
}
Expand Up @@ -25,7 +25,7 @@
/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public class ClientDAO extends GenericDAO<Client> implements CDAO
public class ClientDAO extends TimestampedDAO<Client> implements CDAO
{
Class<Client> entityClass()
{
Expand Down
Expand Up @@ -27,6 +27,8 @@
*/
public interface DAO<T>
{
void save(T t);

T find(Long id);

<U> U find(Class<U> clazz, Long id);
Expand Down
Expand Up @@ -55,5 +55,6 @@ public void testInterceptors(Filter filter) throws Exception
c = filter.check();
Assert.assertNotNull(c);
Assert.assertEquals("TxInterceptor_TEMP", c.name);
filter.save(c);
}
}
Expand Up @@ -31,6 +31,11 @@ public class Filter
{
private CDAO cdao;

public void save(Client c)
{
cdao.save(c);
}

public Client verify()
{
return cdao.find(123L);
Expand Down
Expand Up @@ -33,6 +33,10 @@ public abstract class GenericDAO<T extends Entity> implements DAO<T>
{
abstract Class<T> entityClass();

public void save(T t)
{
}

@Tx(1)
public T find(Long id)
{
Expand Down
@@ -0,0 +1,31 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This 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 software 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 software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.weld.tests.interceptors.tb;

/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public interface TDAO<T extends Timestamped> extends DAO<T>
{
boolean isExpired(T timestamped);
}
@@ -0,0 +1,31 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This 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 software 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 software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.weld.tests.interceptors.tb;

/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public abstract class Timestamped extends Entity
{
Long timestamp;
}
@@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This 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 software 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 software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.weld.tests.interceptors.tb;

/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public abstract class TimestampedDAO<T extends Timestamped> extends GenericDAO<T> implements TDAO<T>
{
public boolean isExpired(T t)
{
return System.currentTimeMillis() - 10000 > t.timestamp;
}
}

0 comments on commit 57a5031

Please sign in to comment.