Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dmitry Kuleshov
committed
Dec 26, 2016
1 parent
f9a91f6
commit 301121d
Showing
67 changed files
with
2,266 additions
and
2,874 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ven-server/src/main/java/org/eclipse/che/plugin/maven/server/PomModificationDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.maven.server; | ||
|
||
import com.google.inject.Inject; | ||
|
||
import org.eclipse.che.api.core.notification.EventService; | ||
import org.eclipse.che.api.project.shared.dto.event.PomModifiedEventDto; | ||
import org.eclipse.che.api.vfs.watcher.FileWatcherManager; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.annotation.PreDestroy; | ||
|
||
import static java.nio.file.Files.isDirectory; | ||
import static org.eclipse.che.api.vfs.watcher.FileWatcherManager.EMPTY_CONSUMER; | ||
import static org.eclipse.che.dto.server.DtoFactory.newDto; | ||
|
||
public class PomModificationDetector { | ||
private static final String POM_XML = "pom.xml"; | ||
|
||
private final FileWatcherManager manager; | ||
private final EventService eventService; | ||
|
||
private int id; | ||
|
||
@Inject | ||
public PomModificationDetector(EventService eventService, FileWatcherManager manager) { | ||
this.eventService = eventService; | ||
this.manager = manager; | ||
} | ||
|
||
@PostConstruct | ||
public void startWatcher() { | ||
id = manager.registerByMatcher(it -> !isDirectory(it) && POM_XML.equals(it.getFileName().toString()), | ||
EMPTY_CONSUMER, | ||
it -> eventService.publish(newDto(PomModifiedEventDto.class).withPath(it)), | ||
EMPTY_CONSUMER); | ||
} | ||
|
||
@PreDestroy | ||
public void stopWatcher() { | ||
manager.unRegisterByMatcher(id); | ||
} | ||
|
||
} |
Oops, something went wrong.