How can we use custom plugin class in Rule

114 views
Skip to first unread message

Kubavat Hardik

unread,
Sep 2, 2014, 1:22:44 AM9/2/14
to idem...@googlegroups.com
Hi,

I have created one new plugin and I configured one rule that using the class from that new plugin. So when this rule is going to execute there is following exception.

WARNING: Sourced file: inline evaluation of: `` import com.centralbos.hr.model.*; import org.compiere.model.*; import org.adempier . . . '' : Typed variable declaration : Class: MConceptOutcome not found in namespace : at Line: 2 : in file: inline evaluation of: `` import com.centralbos.hr.model.*; import org.compiere.model.*; import org.adempier . . . '' : MConceptOutcome  

Class MConceptOutcome  reside in my new plugin, I had already implemented model factory for that class.

Can anyone help, How can we use custom class that resides outside of base plugin in Rule?

Thomas Bayen

unread,
Sep 2, 2014, 4:16:57 AM9/2/14
to idem...@googlegroups.com
Hi,

from your description I can not exactly see if you did a ModelValidator,
a Callout or a Model implementation.

For me it sounds like you did not create the OSGi service-descriptor.
Did you follow:

http://wiki.idempiere.org/en/Category:Plug-In_Development

???

regards,
Thomas Bayen
> --
> You received this message because you are subscribed to the Google
> Groups "iDempiere" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to idempiere+...@googlegroups.com
> <mailto:idempiere+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/idempiere/262328bc-24aa-4db5-ae1d-71415ee1ca24%40googlegroups.com
> <https://groups.google.com/d/msgid/idempiere/262328bc-24aa-4db5-ae1d-71415ee1ca24%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

mit freundlichen Grüßen,

Thomas Bayen
--
Jakob Bayen KG, Bleichpfad 20-22, 47799 Krefeld
AG Krefeld HRA 416 Tel +49/2151/65 80 9-0

hardik.kubavat

unread,
Sep 4, 2014, 5:42:06 AM9/4/14
to idem...@googlegroups.com
Hi Thomas,

Yes we followed the steps as per the link. But the problems is related to classloader. I created my model classes into my custom plugin and the Scriptlet class that I am using to execute the rule script having classloader of base plugin, so script would not found my custom classes into the rule.
So to resolve issue I have override the execute method of Scriplet class in which it will execute the script as per Custom Class loader that we pass to the method.

Regards,
Hardik Kubavat


Jan Thielemann

unread,
Sep 4, 2014, 6:48:35 AM9/4/14
to idem...@googlegroups.com
I think you cannot access your class from the base plugin because:
1. your plugin does not export the class/package
2. the base plugin doesn't has your plugin as dependency

Maybe you can try something like:

PO po = null;
List<IModelFactory> factoryList = Service.locator().list(IModelFactory.class).getServices();
if (factoryList != null)
{
for(IModelFactory factory : factoryList)
{
po = factory.getPO(tableName, Record_ID, trxName);
if (po != null)
{
if (po.get_ID() != Record_ID && Record_ID > 0)
po = null;
else
break;
}
}
}



to load your model class. 


public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
PO po = null;
Method method = po.getClass().getMethod("doSomething", String.class);
method.invoke(po, "Test");
}



I haven't tested it but maybe it gives you an idea. Hopefully it helps you. 

hardik.kubavat

unread,
Sep 5, 2014, 12:12:58 AM9/5/14
to idem...@googlegroups.com
Thanks Jan,

I will look at it.

Regards,
Hardik Kubavat

To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/a360a1e7-0f8b-42be-bd75-b767e00dcb37%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages