1 22 23 package org.jboss.tutorial.ee.service.impl; 24 25 import java.io.Serializable ; 26 import java.util.Set ; 27 import java.util.TreeSet ; 28 import javax.ejb.Remove ; 29 import javax.ejb.Stateful ; 30 import javax.interceptor.Interceptors; 31 32 import org.jboss.annotation.spring.Spring; 33 import org.jboss.spring.callback.SpringLifecycleInterceptor; 34 import org.jboss.tutorial.ee.service.Horoscope; 35 import org.jboss.tutorial.spring.WordsCreator; 36 37 40 @Stateful 41 @Interceptors(SpringLifecycleInterceptor.class) 42 public class HoroscopeBean implements Horoscope, Serializable 43 { 44 45 private static final long serialVersionUID = 2300669204640707036L; 46 47 private Set <String > sentences = new TreeSet <String >(); 48 49 @Spring(jndiName = "spring-pojo", bean = "horoscopeSentenceCreator") 50 private WordsCreator horoscopeCreator; 51 52 public String getHoroscope(int month) 53 { 54 String sentence = horoscopeCreator.createWord(); 55 if (!sentences.add(sentence)) 56 { 57 System.out.println("Repeating horoscope sentence."); 58 } 59 return sentence; 60 } 61 62 @Remove 63 public void clear() 64 { 65 sentences.clear(); 66 } 67 68 } 69 | Popular Tags |