Skip to content

Commit

Permalink
Move activity components to plugin-activity (eclipse-che#5896)
Browse files Browse the repository at this point in the history
Move activity components to plugin-activity
  • Loading branch information
mkuznyetsov authored and Dmytro Nochevnov committed Aug 16, 2017
1 parent 4291fed commit 83e5f47
Show file tree
Hide file tree
Showing 32 changed files with 535 additions and 68 deletions.
4 changes: 4 additions & 0 deletions assembly/assembly-ide-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-ide-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-activity-ide</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-composer-ide</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions assembly/assembly-wsagent-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<groupId>org.eclipse.che.lib</groupId>
<artifactId>che-swagger-module</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-activity-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-composer-server</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions assembly/assembly-wsmaster-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@
<groupId>org.eclipse.che.lib</groupId>
<artifactId>che-swagger-module</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-activity-wsmaster</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-docker-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected void configure() {
Multibinder.newSetBinder(binder(), org.eclipse.che.api.machine.server.spi.InstanceProvider.class);
machineImageProviderMultibinder.addBinding().to(org.eclipse.che.plugin.docker.machine.DockerInstanceProvider.class);

install(new org.eclipse.che.api.workspace.server.activity.inject.WorkspaceActivityModule());
install(new org.eclipse.che.plugin.activity.inject.WorkspaceActivityModule());

bind(org.eclipse.che.api.environment.server.MachineInstanceProvider.class)
.to(org.eclipse.che.plugin.docker.machine.MachineProviderImpl.class);
Expand Down
7 changes: 7 additions & 0 deletions dockerfiles/init/manifests/che.env
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@
# Defaults to the same value of CHE_WORKSPACE_JAVA_OPTIONS.
#CHE_WORKSPACE_MAVEN_OPTIONS=NULL

# Workspace Idle timeout
# The length of time after which workspaces will be automatically stopped, if no activity
# has been detected on them. Currently, keyboard and mouse interactions in IDE, as well as HTTP
# requests to ws-agent count as activity. Set "0" to disable automatic stop of inactive workspaces.
# Default to the value of this property in che.properties (3600000)
#CHE_WORKSPACE_AGENT_DEV_INACTIVE__STOP__TIMEOUT__MS=0

########################################################################################
##### #####
##### NETWORKING #####
Expand Down
53 changes: 53 additions & 0 deletions plugins/plugin-activity/che-plugin-activity-ide/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2017 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
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-activity-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.17.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>che-plugin-activity-ide</artifactId>
<packaging>jar</packaging>
<name>Che Plugin :: Activity :: IDE</name>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-gwt</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-api</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (c) 2012-2017 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.activity.ide;


import com.google.gwt.core.client.Callback;
import com.google.gwt.core.client.ScriptInjector;

import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.extension.Extension;
import org.eclipse.che.ide.rest.RestContext;

import javax.inject.Inject;
import javax.inject.Singleton;

import static com.google.gwt.core.client.ScriptInjector.TOP_WINDOW;

/**
* Adds activity tracking script to IDE.
*
* @author Max Shaposhnik (mshaposhnik@codenvy.com)
*/
@Singleton
@Extension(title = "Activity Tracking Extension", version = "1.0.0")
public class ActivityTrackingExtension {

@Inject
public ActivityTrackingExtension(final @RestContext String restContext,
final AppContext appContext) {

ScriptInjector.fromUrl("/_app/activity.js")
.setWindow(TOP_WINDOW)
.setCallback(new Callback<Void, Exception>() {
@Override
public void onSuccess(Void result) {
init(restContext, appContext.getWorkspaceId());
}

@Override
public void onFailure(Exception reason) {
}

private native void init(String restContext, String wsId) /*-{
$wnd.ActivityTracker.init(restContext, wsId);
}-*/;
})
.inject();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
Copyright (c) 2012-2017 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
-->
<module>
<inherits name="com.google.gwt.user.User"/>

<public path="public"/>

<source path="ide"/>
</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2012-2017 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
*/
var ActivityTracker = new function () {

var url;
var timeoutInterval = 30000;
var maxErrors = 10;
var errors = 0;
var active;

this.init = function (restContext, workspaceId) {
this.url = restContext + "/activity/" + workspaceId;
document.addEventListener("mousemove", ActivityTracker.setActive);
document.addEventListener("keypress", ActivityTracker.setActive);
setInterval(ActivityTracker.sendRequest, timeoutInterval);

};

this.setActive = function() {
if (!active && errors < maxErrors) {
active = true;
}
}


this.sendRequest = function () {
if (!active) {
return;
}
active = false;

var request;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
} else {
request = new ActiveXObject("Microsoft.XMLHTTP");
}

request.onreadystatechange = function () {
if (request.readyState == 4) {
if (request.status == 204) {
errors = 0;
} else {
errors++;
}

}
};
request.open("PUT", ActivityTracker.url, true);
request.send();
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@
Codenvy, S.A. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-agent-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-plugin-activity-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.17.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>activity</artifactId>
<name>Che Core :: API :: Activity</name>
<artifactId>che-plugin-activity-server</artifactId>
<packaging>jar</packaging>
<name>Che Plugin :: Activity :: Server</name>
<dependencies>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
Expand All @@ -29,6 +35,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-schedule</artifactId>
Expand All @@ -42,11 +52,6 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2012-2017 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.activity;

import com.google.inject.servlet.ServletModule;

import org.eclipse.che.inject.DynaModule;

/**
* @author Mihail Kuznyetsov
*/
@DynaModule
public class ActivityServletModule extends ServletModule {

@Override
protected void configureServlets() {
filter("/*").through(org.eclipse.che.plugin.activity.LastAccessTimeFilter.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.api.activity;
package org.eclipse.che.plugin.activity;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.api.activity;
package org.eclipse.che.plugin.activity;

import org.eclipse.che.api.core.rest.HttpJsonRequestFactory;
import org.eclipse.che.commons.schedule.ScheduleRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.api.activity;
package org.eclipse.che.plugin.activity;


import org.mockito.InjectMocks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.api.activity;
package org.eclipse.che.plugin.activity;

import org.eclipse.che.api.core.rest.HttpJsonRequestFactory;
import org.mockito.Mock;
Expand All @@ -17,7 +17,6 @@
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

Expand Down
25 changes: 25 additions & 0 deletions plugins/plugin-activity/che-plugin-activity-shared/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2017 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
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-activity-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.17.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>che-plugin-activity-shared</artifactId>
<packaging>jar</packaging>
<name>Che Plugin :: Activity :: Shared</name>
</project>
Loading

0 comments on commit 83e5f47

Please sign in to comment.