Hi All,

 With you help I have been developing a small
application. The goal is very simple, we have 3
GBeans: MyGBean, APrinterGBean and BPrinterGBean.
MyGBean invokes a "print" operation on the two
printers which it references and gets via dependency
injection.

 MyGBean prints "MyGBean" when started. For the other
two GBeans, they have public "print" operations that
when invoked (by MyGBean in this case) they output
"APrinterGBean" and "BPrinterGBean" respectively.  So,
if all were working correctly, we would see the
sequence:

"MyGBean"
"APrinterGBean"
"BPrinterGBean"

  If I run MyGBean without referencing any of the
printer GBeans, I get the correct message: "MyGBean."
However, when I do handle the references for
APrinterGBean and BPrinterGBean, I am able to compile
and deploy the configuratiion plan successfuly, but
only APrinterGBean and BPrinterGBean get started and
as a result nothing gets printed. It is puzzling that
it seems to be working fine, but MyGBean just doesn't
get started, because if it were, we would see the
sequence of the three messages:

"MyGBean"
"APrinterGBean"
"BPrinterGBean"


Any idea on why this is happening ? It all seems to be
done properly, so I am a bit surprised. The
configuration plan that I am using is:


<?xml version="1.0" encoding="UTF-8"?>
        
<configuration
          
xmlns="http://geronimo.apache.org/xml/ns/deployment";
           configId="task/SampleTask"
           >
         
                <dependency>            
                        <groupId>samples</groupId>
                        <artifactId>task</artifactId>
                        <version>1.0</version>                  
                </dependency>                           
                                    
        <gbean name="gbean1" class="task.APrinterGBean">
</gbean>           
        
        <gbean name="gbean2" class="task.BPrinterGBean">
</gbean>           
        
        <!--
                 <gbean name="DefaultThreadPool"
class="org.apache.geronimo.pool.ThreadPool">
                <attribute
name="keepAliveTime">15000</attribute>
                <attribute name="poolSize">30</attribute>
                <attribute
name="poolName">DefaultThreadPool</attribute>
        </gbean> -->
         
                <gbean name="MyGBean" class="task.MyGBean">
                <!-- <reference
name="Executor"><name>DefaultThreadPool</name></reference>
 -->
                    <reference name="APrinter">
<name>APrinterGBean</name> </reference>      
                        <reference name="BPrinter">
<name>BPrinterGBean</name> </reference> 
                </gbean> 
                                                                            
                <!-- <gbean name="PrintStopper"
class="task.PrintStopper" /> </gbean> --> 
                                                                                
</configuration>
        


The MyGBean looks as follows:


public class MyGBean implements GBeanLifecycle {

...

    private APrinterGBean APrinter;
    private BPrinterGBean BPrinter;

...

    public void setAPrinter( APrinterGBean APrinter )
{
        this.APrinter = APrinter;              
    }
    
    public void setBPrinter( BPrinterGBean BPrinter )
{
        this.BPrinter = BPrinter;               
    } 

...

   
infoFactory.addReference("APrinter",APrinterGBean.class);
   
infoFactory.addReference("BPrinter",BPrinterGBean.class);
  

...

public void doStart() throws WaitingException,
Exception {
        System.out.println("GBean: " + objectName + " has
started");
        log.info("My GBean has started");
        log.info(objectName);
        log.info( "bean1 = " + APrinter);
        log.info( "bean2 = " + BPrinter);             
            
        print(); //prints: MyGBean
        APrinter.print(); //prints: "APrinterGBean"
        BPrinter.print(); //prints: "BPrinterGBean"  
    }


Clearly, the doStart() of MyGBean operation is not
being executed, but I dont get any error messages
related to MyGBean on the console nor on the log
files. 

So, the issue here is that the configuration plan is
deployed correctly, APrinterGBean and BPrinterGBean
get started, but MyGBean is not getting started.

Finally, in the next step of my little project I will
make both APrinterGBean and BPRinterGBean run each on
a ThreadPool. Each will run an infinite loop and I
will create a fourth GBean whose sole purpose will be
to stop the two printers. You can see the beginnings
of this in the commented sections of my config plan
above.

After I am done, I can post the whole project, so that
others can learn from it. The Internet is full of
examples with code that does not compile, so I am sure
this my code will be useful to others.

Thanks,
NP.









__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to