GIN & Piriti

29 views
Skip to first unread message

Aladdin

unread,
Apr 3, 2012, 6:00:19 AM4/3/12
to Piriti
Hi,

I'm having a problem mixing GIN and Piriti. As you can see the
"Dynamic" object has no default constructor and is this causing an
error because Piriti tries to initiate it outside GIN, even that I
used GIN to get Piriti started. For sure "Dynamic" works correctly
without Piriti and GIN injects the workflowController with a
DefaultWorkflowController.


Please help and thanks in advance.


public class Dynamic {

@Path("serviceGroup") List<ServiceGroup> serviceGroups;

WorkflowController workflowController;

@Inject
public Dynamic(WorkflowController workflowController) {
this.workflowController=workflowController;
}
...
}

...

public class DynamicFormModule extends AbstractGinModule {

@Override
protected void configure() {
bind(WorkflowController.class).to(DefaultWorkflowController.class);
}
}

....


@GinModules(DynamicFormModule.class)
public interface DynamicFormGinjector extends Ginjector {
DynamicXML getDynamicXML();
Dynamic getDynamic();

}

Aladdin

unread,
Apr 3, 2012, 8:48:03 AM4/3/12
to Piriti
To clarify my question, I need Piriti to use GIN to initiate my
classes, i.e initiate Dynamic through GIN and in that way GIN will
notice the @inject and inject the DefaultWorkflowController class into
the workflowController field.


Thanks again.

Harald Pehl

unread,
Apr 3, 2012, 9:59:13 AM4/3/12
to pir...@googlegroups.com
What about using an InstanceCreator:


@CreateWith(DynamicCreator.class)
public class Dynamic { 
    ...
}

public class DynamicCreator extends XmlInstanceCreator<Dynamic> {
    public Dynamic newInstance(Node context) {
        DynamicFormGinjector injector = GWT.create(DynamicFormGinjector.class);
        Dynamic instance = injector.getDynamic();
        return instance;
    }
}


This way new instances of Dynamic are not created using GWT.create(Dynamic.class) but the specified InstanceCreator.

- Harald
Reply all
Reply to author
Forward
0 new messages