-
1. Re: How to fetch value for annotation from standalone.xml
sfcoy Jul 19, 2013 6:31 AM (in response to streety)Which annotation?
What kind of java class?
-
2. Re: How to fetch value for annotation from standalone.xml
streety Jul 19, 2013 7:34 AM (in response to sfcoy)Here is a code sample..
@Singleton
public class Abcd {
@PersistenceContext(unitName = "mno")
private EntityManager em;
private Class<? extends Object> clazz = Abcd.class;
private Logger logger = LogManager.getLogger(clazz);
@Schedule(second="*/20", minute="*/20",hour="*", persistent=false)
public void run() {
TypedQuery<Site> query = em.createQuery("some query", SomeClass.class);
List<Site> siteList = query.getResultList();
Date now = new Date();
for ( SomeClass someClass : SomeClassList) {
Abcd( someClass, now);
}
}
_______________________________________________________________________________
I want to give the value to second,minutes and persistent from standalone.xml but its saying annotation can have only constant value??
-
3. Re: How to fetch value for annotation from standalone.xml
sfcoy Jul 19, 2013 7:40 AM (in response to streety)You need to use javax.ejb.TimerService#createCalendarTimer(javax.ejb.ScheduleExpression) to do that. Call it from an @PostCreate method.
-
4. Re: How to fetch value for annotation from standalone.xml
streety Jul 19, 2013 8:26 AM (in response to sfcoy)I tried searching example based on createCalenderTimer but I got almost same kind of implementation. Every where they are just using annotated constant value. My question still remains same.
-
5. Re: How to fetch value for annotation from standalone.xml
sfcoy Jul 22, 2013 8:11 AM (in response to streety)Example attached.
You need maven 3.0.x to build it.
It can also be imported into Eclipse Kepler JavaEE edition + JBoss Tools 4.1.
In addition it contains a command line script to set up the JNDI entries in standalone.xml.
-
ext-configured-ejb-timer.zip 5.3 KB
-
-
6. Re: How to fetch value for annotation from standalone.xml
streety Jul 22, 2013 9:24 AM (in response to sfcoy)Thanks for your concern Stephen.Really appreciate it. Meanwhile I was working like using ejb Timer Service which take value as a parameter from standalone.xml. But now I face the problem that the its not been called even once.
Right now I have one instance of TimerService and that run method has been annotated as @Timeout.
Anyhow Thanks
-
7. Re: How to fetch value for annotation from standalone.xml
sfcoy Jul 22, 2013 9:40 AM (in response to streety)My example runs at the 20 second mark of every minute. Maybe that will tip you off...
-
8. Re: How to fetch value for annotation from standalone.xml
streety Jul 22, 2013 10:08 AM (in response to sfcoy)Your example looks good. Only the config_context looks bit confusing. May be because u r using jboss 4.1....its like that. And my question where u propose me to call that run method.
update::
DONE!!!
-
9. Re: How to fetch value for annotation from standalone.xml
sfcoy Jul 22, 2013 10:40 AM (in response to streety)I tried this on JBossAS 7.1.1.Final and 7.2.0.Final. But not 4.1...