[jboss-user] [JBoss Seam] - Re: How to use @Startup annotation?

surajmundada@yahoo.com do-not-reply at jboss.com
Tue Jun 5 00:07:59 EDT 2007


Thanks for the reply. 

Here is the code. 


  | 
  | 	@Startup
  | 	@Scope(ScopeType.APPLICATION)
  | 	@Name("populateCommercialStripsListener")
  | 	public class PopulateCommercialStripsListener
  | 	{
  | 		
  | 		private Logger logger = Logger.getLogger(PopulateCommercialStripsListener.class);
  | 		private LoggingHelper helper = LoggingHelper.getInstance();
  | 		
  | 		private StripTypePE stripTypePE;
  | 		
  | 		@Create
  | 		public void populateCommercialStrips() 
  | 		{
  | 			try 
  | 			{
  | 				// Initialize different modules we reuse from ATB new application.
  | 				QatbApplicationControl.initQATBComponents();
  | 			    
  | 				// Get the complete list of commercial strips - It returns a map containing the strip names as keys and strip code as values.
  | 				// We have chosen to put the strip names as keys because the calling program will get the strip description from its name. 
  | 				Map listOfStrips = QATBCommercialStripsManager.getInstance().getListOfStripNames();
  | 				Iterator iteratorOnStripNames = listOfStrips.keySet().iterator();
  | 
  | 				stripTypePE = new StripTypePE(MiscellaneousConstants.COMMERCIAL_STRIP_TYPE, 
  | 						MiscellaneousConstants.COMMERCIAL_STRIP_TYPE_NAME,
  | 						MiscellaneousConstants.COMMERCIAL_STRIP_TYPE_DESCRIPTION);  
  | 
  | 				
  | 				// Display the composition for the strips stored in the database 
  | 				Long id = MiscellaneousConstants.COMMERCIAL_STRIP_INITIAL_PK;
  | 				
  | 				StripDS stripDSImpl = (StripDS)Component.getInstance("stripDSImpl",true);
  | 				
  | 				while (iteratorOnStripNames.hasNext()) 
  | 				{
  | 					String stripName = (String) iteratorOnStripNames.next();				
  | 					String stripCode = (String) listOfStrips.get(stripName);
  | 					ATBStripDescription strip = QATBCommercialStripsManager.getInstance().getCommercialStrip(stripCode);
  | 					
  | 					if(stripDSImpl.getStripPE(id) == null)
  | 					{
  | 						StripPE objStripPE = createCommercialStrip(strip,id);
  | 						
  | 						if(objStripPE != null)
  | 						{
  | 							populateStripInfo(strip,id,objStripPE);
  | 						}
  | 					}
  | 					
  | 					id++;
  | 				}
  |                        }
  |                        catch ()
  |                         {
  |                              ........
  |                         }
  |               }
  | 
  | 

StripTypePE is an EJB3 enitity with Session scope. 
stripDSImpl is DAO with Session scope.


  | 
  | @Stateless
  | @Name("stripDSImpl")
  | @Scope(SESSION)
  | public class StripDSImpl implements StripDS
  | {
  |          ........
  |          ........
  | }
  | 
  | 
  | @Entity
  | @Table(name = "STRIP_TYPE", uniqueConstraints =
  | { @UniqueConstraint(columnNames ={ "NAME" }) })
  | @Name("stripTypePE")
  | @Scope(SESSION)
  | public class StripTypePE implements Serializable
  | {
  |      ........
  |      ........
  | }
  | 

is the Session scope of these two classes the root of the problem of "No session context active"? 

Regards, 

Suraj

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4051160#4051160

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4051160



More information about the jboss-user mailing list