Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Can't Use Services in My Project(Neither I can use auto-generated default Services.class nor my CustomService.class that I created)
Can't Use Services in My Project [message #1781011] Wed, 31 January 2018 14:43 Go to next message
Utku Demir is currently offline Utku DemirFriend
Messages: 8
Registered: October 2017
Junior Member
Hi,

First of all,
1- Yes, I can use the Services.class in the Family Example provided by Sirius.
2- Yes, I can use the CustomService.class that I created myself in the Family Example.
3- Yes, I created Java Extensions with correct Qualified Class Name to use default Service.java or my CustomService.java
4- No, I don't have any problem while calling services from expressions with "service:getService" in the Family Example.

Now my problem is pretty obvious,

1- I can't use Service.class that auto-generated by default. It comes like this:
public class Services {
    
    /**
    * See http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.sirius.doc%2Fdoc%2Findex.html&cp=24 for documentation on how to write service methods.
    */
    public EObject myService(EObject self, String arg) {
       // TODO Auto-generated code
      return self;
    }
}



1.a- Also I can't even use a simple method like simply returning Integer "1":
public class CustomService {
	
	public int getNumber(Param param) {
		
		return 1;
	}

}


2- I can't use my CustomService.class that I created. Yes, I created Java Extensions with correct Qualified Class Name to use it but in console it says couldn't find:

!MESSAGE Could not find Java extension class org.eclipse.sirius.thy.system.design.CustomService
!STACK 0
java.lang.RuntimeException
	at org.eclipse.sirius.common.tools.internal.interpreter.ServiceInterpreter$1.notFound(ServiceInterpreter.java:82)
	at org.eclipse.sirius.common.tools.api.interpreter.JavaExtensionsManager.notFound(JavaExtensionsManager.java:544)
	at org.eclipse.sirius.common.tools.api.interpreter.JavaExtensionsManager.loadJavaExtensions(JavaExtensionsManager.java:537)
	at org.eclipse.sirius.common.tools.api.interpreter.JavaExtensionsManager.reloadIfNeeded(JavaExtensionsManager.java:244)
	at org.eclipse.sirius.common.tools.internal.interpreter.ServiceInterpreter.getServices(ServiceInterpreter.java:269)
	at org.eclipse.sirius.common.ui.tools.internal.interpreter.ServiceProposalProvider.getProposals(ServiceProposalProvider.java:71)
	at org.eclipse.sirius.common.tools.api.interpreter.CompoundInterpreter.getProposals(CompoundInterpreter.java:679)
	at org.eclipse.sirius.ui.tools.api.assist.TextContentProposalProvider.getProposals(TextContentProposalProvider.java:85)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter.getProposals(ContentProposalAdapter.java:2005)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter.openProposalPopup(ContentProposalAdapter.java:1854)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter.access$16(ContentProposalAdapter.java:1849)
	at org.eclipse.jface.fieldassist.ContentProposalAdapter$1.handleEvent(ContentProposalAdapter.java:1720)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1130)
	at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1789)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1126)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1547)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4962)
	at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2722)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4843)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2704)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5178)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2560)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3815)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1472)


I don't know if it's a bug or something but I'm looking for solution ideas as soon as possible :)

PS: Eclipse Version: Oxygen.1a Release (4.7.1a)
Build id: 20171005-1200
Sirius Version: 5.0..




Thanks,
Utku Demir

[Updated on: Wed, 31 January 2018 16:01]

Report message to a moderator

Re: Can't Use Services in My Project [message #1781020 is a reply to message #1781011] Wed, 31 January 2018 15:47 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

1. When a service is invoked, the model element on which it is invoked is used as the first argument to the Java method. If arguments are passed in the expression, they are mapped to the second, third, etc. parameters of the Java method, assuming the types are compatible. [1]
This is why you should call "service:myService(String)" for a method with signature "public EObject myService(EObject self, String arg) {". Your service getNumber() is not accessible because there is no parameter.

2. Why are you using/referencing a .class instead of a .java? Either way, if you look at the default java extension for "Services", the java extension is not in Qualified class name field.
Is it in a different compiled project/library? If I remember correctly we are limited to have java services in the same plugin.

Regards,
Steve

[1] https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Can't Use Services in My Project [message #1781025 is a reply to message #1781020] Wed, 31 January 2018 16:18 Go to previous message
Utku Demir is currently offline Utku DemirFriend
Messages: 8
Registered: October 2017
Junior Member
Hi Steve,

Thanks for your kind answers. Because of rush I couldn't express my real thoughts in this write. Sorry for misdirection you.

1- Yes, ofc you are right about the parameters. I poorly described my real problem here.

2- Again, my fault while writing Java class names, thanks to you I updated the post.

Also UPDATE 1: I figured out that without re-opening the Eclipse-Runtime Application it gives the "!MESSAGE Could not find Java extension class org.eclipse.sirius.thy.system.design.CustomService" but after re-opening it worked fined.



Steve Monnier wrote on Wed, 31 January 2018 15:47
Hello,

1. When a service is invoked, the model element on which it is invoked is used as the first argument to the Java method. If arguments are passed in the expression, they are mapped to the second, third, etc. parameters of the Java method, assuming the types are compatible. [1]
This is why you should call "service:myService(String)" for a method with signature "public EObject myService(EObject self, String arg) {". Your service getNumber() is not accessible because there is no parameter.

2. Why are you using/referencing a .class instead of a .java? Either way, if you look at the default java extension for "Services", the java extension is not in Qualified class name field.
Is it in a different compiled project/library? If I remember correctly we are limited to have java services in the same plugin.

Regards,
Steve

[1] https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods



Thanks,
Utku Demir
Previous Topic:SVG references not working
Next Topic:[ANN] Sirius 5.1.1
Goto Forum:
  


Current Time: Tue Apr 16 15:33:03 GMT 2024

Powered by FUDForum. Page generated in 1.30079 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top