[Design the new POJO MicroContainer] - Re: Microcontainer + Guice
by alesj
I've also added a way to do injection the other way around: from Guice into MC.
| AbstractBeanMetaData guicePlugin = new AbstractBeanMetaData("GuicePlugin", GuiceKernelRegistryEntryPlugin.class.getName());
| AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
| AbstractArrayMetaData arrayMetaData = new AbstractArrayMetaData();
| final Singleton singleton = new Singleton();
| Module module = new AbstractModule()
| {
| protected void configure()
| {
| bind(Singleton.class).toInstance(singleton);
| }
| };
| arrayMetaData.add(new AbstractValueMetaData(module));
| constructor.setParameters(Collections.singletonList((ParameterMetaData)new AbstractParameterMetaData(arrayMetaData)));
| guicePlugin.setConstructor(constructor);
| controller.install(guicePlugin);
|
| BeanMetaData holderBean = new AbstractBeanMetaData("holder", SingletonHolder.class.getName());
| controller.install(holderBean);
|
| ControllerContext holderContext = controller.getInstalledContext("holder");
| assertNotNull(holderContext);
| SingletonHolder holder = (SingletonHolder)holderContext.getTarget();
| assertNotNull(holder);
| assertEquals(singleton, holder.getSingleton());
|
|
The detail is in GuiceKernelRegistryEntryPlugin, which acts as a middle man between MC registry and Guice Injector instance.
| public class GuiceKernelRegistryEntryPlugin implements KernelRegistryPlugin
| {
| private Injector injector;
|
| public GuiceKernelRegistryEntryPlugin(Module... modules)
| {
| injector = Guice.createInjector(modules);
| }
|
| public void destroy()
| {
| injector = null;
| }
|
| public KernelRegistryEntry getEntry(Object name)
| {
| KernelRegistryEntry entry = null;
| try
| {
| if (name instanceof Class<?>)
| {
| Class<?> clazz = (Class<?>)name;
| entry = new AbstractKernelRegistryEntry(name, injector.getInstance(clazz));
| }
| else if (name instanceof Key)
| {
| Key<?> key = (Key<?>)name;
| entry = new AbstractKernelRegistryEntry(name, injector.getInstance(key));
| }
| }
| catch (Exception ignored)
| {
| }
| return entry;
| }
| }
|
MC documentation has already been updated with this new Guice-int module.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4088760#4088760
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4088760
17 years, 3 months
[Design of JBoss jBPM] - [GPD 3.1.0.SP1] NPE when opening process
by laurenzo
Hi,
I am trying to open the loan broker process provided with the mule project examples.
http://mule.codehaus.org/display/MULE/Loan+Broker+Example
GPD fails to open with NPE stack trace provided below. This was on version 3.1.0.CR1. I thought the fix of GPD-148 http://jira.jboss.com/jira/browse/GPD-148 would help but this issue is still present in 3.1.0.SP1 as well.
I would create a JIRA issue but can't seem to get access to the "new issue" feature. Let me know how to proceed if required.
Thanks
L.
Eclipse Europa/Windows
=============================================
<?xml version="1.0" encoding="UTF-8"?>
<process-definition name="LoanBroker"
xmlns="http://jbpm.org/3/jpdl"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jbpm.org/3/jpdl http://jbpm.org/jpdl-3.1.xsd">
<!-- *******************************************************************
Loan Broker Process Definition
******************************************************************* -->
<!-- Request received from customer -->
<start-state name="customerRequest">
</start-state>
CustomerRequests
<!-- We could perform additional data validation here
-->
customerRequest
<!-- Send customer info. to credit agency -->
<!-- This is the variable we stored in the previous step -->
customerRequest.customer
CreditAgency
false
<!-- Wait for the customer's credit profile to arrive. -->
CreditProfiles
<!-- We could perform additional data validation here
-->
creditProfile
<!-- Prepare a quote request to send to the banks which includes the customer's credit info. -->
<!-- Send the request to one of three banks, depending on the loan amount and customer credit info. -->
<![CDATA[#{customerRequest.loanAmount >= 20000}]]>
<![CDATA[#{creditProfile.creditHistory >= 24}]]>
<![CDATA[#{creditProfile.creditScore >= 5}]]>
BigBank
loanRequest
<![CDATA[#{customerRequest.loanAmount >= 10000}]]>
<![CDATA[#{creditProfile.creditHistory >= 12}]]>
<![CDATA[#{creditProfile.creditScore >= 3}]]>
MediumBank
loanRequest
<![CDATA[#{customerRequest.loanAmount < 10000}]]>
<![CDATA[#{creditProfile.creditHistory >= 6}]]>
<![CDATA[#{creditProfile.creditScore >= 1}]]>
SmallBank
loanRequest
<!-- If the credit info. doesn't meet minimum requirements based on the loan amount,
the loan is just denied. -->
org.mule.examples.loanbroker.messages.LoanQuote
<!-- We could perform additional data validation here
-->
<!-- Send the final loan quote back to the customer. -->
CustomerResponses
false
<end-state name="loanApproved" />
<end-state name="loanDenied" />
</process-definition>
=============================================
java.lang.NullPointerException
at org.jbpm.gd.jpdl.deployment.DeploymentForm.createIncludeClassesSection(Unknown Source)
at org.jbpm.gd.jpdl.deployment.DeploymentForm.create(Unknown Source)
at org.jbpm.gd.jpdl.editor.JpdlDeploymentEditorPage.createForm(Unknown Source)
at org.jbpm.gd.jpdl.editor.JpdlDeploymentEditorPage.createPartControl(Unknown Source)
at org.eclipse.ui.part.MultiPageEditorPart.addPage(MultiPageEditorPart.java:190)
at org.jbpm.gd.common.editor.Editor.addPage(Unknown Source)
at org.jbpm.gd.jpdl.editor.JpdlEditor.createPages(Unknown Source)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:283)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:661)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:426)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:592)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:299)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:179)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:268)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:400)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1256)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1209)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1604)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:217)
at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:207)
at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:774)
at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:673)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:634)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2719)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2633)
at org.eclipse.ui.internal.WorkbenchPage.access$12(WorkbenchPage.java:2625)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2577)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2572)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2556)
at org.eclipse.ui.actions.OpenWithMenu.openEditor(OpenWithMenu.java:340)
at org.eclipse.ui.actions.OpenWithMenu.access$0(OpenWithMenu.java:328)
at org.eclipse.ui.actions.OpenWithMenu$2.handleEvent(OpenWithMenu.java:190)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4088655#4088655
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4088655
17 years, 3 months