package demo;

import java.util.*;
import javax.ejb.*;
import javax.naming.*;

/**
 * Represents a news-story
 *
 * @ejb-remote
 * @ejb-entity
 * @ejb-key-generate
 * @ejb-persistence-type        Container
 * @ejb-cmp-table               STORY
 */
public abstract class StoryBean {

    //---( Fields )---

    /**
     * @ejb-remote
     * @ejb-key-field
     * @ejb-cmp-column ID
     */
    public abstract long getId();

    protected abstract void setId( long id );

    /**
     * @ejb-remote
     * @ejb-cmp-column AUTHOR
     */
    public abstract String getAuthor();

    /**
     * @ejb-remote
     */
    public abstract void setAuthor( String author );

    /**
     * @ejb-remote
     * @ejb-cmp-column SUBJECT
     */
    public abstract String getSubject();

    /**
     * @ejb-remote
     */
    public abstract void setSubject( String subject );

    /**
     * @ejb-remote
     * @ejb-cmp-column CONTENT
     */
    public abstract String getContent();

    /**
     * @ejb-remote
     */
    public abstract void setContent( String content );

    //---( Create/Remove )---

    /**
     * Create a new Story.
     * @ejb-remote
     */
    public StoryKey ejbCreate( String author, String subject )
        throws CreateException
    {
        setId( System.currentTimeMillis() );
        setAuthor( author );
        setSubject( subject );
        return null;
    }

    /**
     * Create a new Story.
     */
    public void ejbPostCreate( String author, String subject )
    {
    }

    /**
     * @ejb-remote
     */
    public void ejbRemove() throws RemoveException {}

    //---( Finders )---

    public interface CMP {
        
        /**
         * @ejb-remote
         * @jboss-cmp-query      	where ID = {0}
         * @weblogic-finder-query 	(= ID $0)
         */
        public StoryKey ejbFindById( long id )
            throws FinderException;
        
        /**
         * @ejb-remote
         * @jboss-cmp-query             where AUTHOR = {0}
         * @weblogic-finder-query       (= AUTHOR $0)
         */
        public StoryKey ejbFindByAuthor( String author )
            throws FinderException;
        
    }
    
    //---( Lifecycle )---

    public void setEntityContext( EntityContext entityContext ) {}
    public void unsetEntityContext() {}
    
    public void ejbActivate() {}
    public void ejbPassivate() {}

    public void ejbLoad() {}
    public void ejbStore() {}
    
}