If you want a factory to be used, you need to go another direction.

when you use <invoke-factory...><construct class="..."

hivemind uses its own factory to instansiate the specified class, call the initialize-method (but ignore the return object) and then autowires the instance...

now if you need your own factory, which is normally the case if the service is *not* a simple bean with a no argument constructor, you need to implement ServiceImplementationFactory, set your implementation as an independant service, and then use

<implementation>
  <invoke-factory service-id="MyFactoryServiceId" model="singleton"/>
</implementation>

Cheers,
Ron


Jason Suplizio wrote:
Hello all,
I've been spinning my wheels over this all day. I have 2 things I'm trying
to accomplish:
1- Wire up Hivemind to get singleton and inject it into my page.
2- If necessary, since I can not serialize my providers, data squeeze the
singleton.

Essentially, I call a synchronized current() method on a provider (with a
private constructor), which returns the singleton. My provider implements a
factory interface used to build the object returned.

This is where I'm at...please see if you can help!

hivemodule.xml
<service-point  id="report" interface="com.myApp.ReportFactory"/>

    <implementation service-id="reportMap">
        <invoke-factory model="singleton">
          <construct class="com.myApp.ReportProvider"
initialize-method="current"/>
       </invoke-factory>
    </implementation>

MyPage.page
    <inject object="service:myReportingApp.reportMap" property="provider"/>

MyPage.java
public abstract AdminReportMapFactory getProvider();

ReportProvider .java
public class ReportProvider implements ReportFactory {

    private static ReportProvider current = null;
    private ReportProvider() {
        // default constructor - needs to be private to enforce singleton
nature
        super();
    }

    /**
     * Get the singleton instance
     * @return ReportProvider
     */
    public static synchronized ReportProvider current() {
        if (current == null) {
            current = new ReportProvider();
        }
        return current;
}
public List lookup(String name, String reportID) {
        return getFactory().lookupReportID(name, reportID);
    }

private ReportFactory getFactory() {
        return ReportFactoryImpl.getInstance();
    }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to