Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [che-dev] ProjectCreatedEvent question

Hi Itai,

I shared your message to che-dev mailing list.

For handlers registration.
Both approaches are valid, it depends on where you want to listen it and how to react.
First approach is more generic and likely more applicable when you want to listen for events in other Service.
Second is convenient if you need to extend or change your Project Type functionality.
For me it more likely you need second one. If you still have doubts let me know what exactly you want to do.

For service creation.
It should be just valid REST service which path does not conflict with other services (we will improve it to make such a conflict  impossible in future). No other requirements.

HTH,
Cheers


Gennady Azarenkov - CTO @ codenvy.com


On Sun, Mar 22, 2015 at 5:26 PM, Fonio, Itai <itai.fonio@xxxxxxx> wrote:

Hello Gennady

 

I am a developer in the DevX team, Israel.

 

We are studying the codenvy code in order to learn how to add an extension, that responds to a specific event (e.g. a new project creation of a specific type), in addition to other capabilities.

 

I came up with these questions that I hope you can answer, or refer me to the right contact.

 

Event registration

I see there are two options involving the ProjectCreatedEvent:

 

1.       Creating a subscriber \\ private final EventSubscriber<ProjectCreatedEvent> projectSubscriber;

And then subscribing it to the EventService singleton \\ eventService.subscribe(projectSubscriber);

 

2.  Registering a new CreatedProjectHandler directly to the ProjectHandlerRegistry singletion \\  phRegistry.register(new CreateProjectHandler() {...});

 

Regarding option #2 – the ProjectHandlerRegistry holds a map that enables a single handler for each project type (see ProjectHandlerRegistry.register()), that practically eliminates this approach.

But the tests for the codenvy-api-project use this method.

 

Can you explain which event handling approach is the best?

 

Service Creation

I noticed that a "simple service" (e.g. HelloWorldService.java under the server-side-tutorial) is not inheriting anything, and constructs a new instance during each REST requests.

On the other hand, the RunnerService for example extends service, that maintains static constructs and would probably be better for creating subscribers.

 

Is there any oter considerations I should take in mind when choosing which service type to implement?

 

10X in advance, Itai



Back to the top