Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Moving deprecated Job APIs to legacy #482

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.xwiki.job.event.JobStartedEvent;
import org.xwiki.job.event.status.JobStatus;
import org.xwiki.job.event.status.QuestionAnsweredEvent;
import org.xwiki.job.internal.AbstractJobStatus;
import org.xwiki.job.AbstractJobStatus;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This impacts a condition in #onJobStarted which is called from #onEvent hence the legacy class I added to support the condition with the old class.

Copy link
Member

@tmortagne tmortagne Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those should have moved to org.xwiki.job.AbstractJobStatus back when it was introduced. There is no need to introduce any legacy for this change, as org.xwiki.job.internal.AbstractJobStatus is a org.xwiki.job.AbstractJobStatus too.

import org.xwiki.observation.AbstractEventListener;
import org.xwiki.observation.event.Event;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<description>XWiki Commons - Job - API</description>
<properties>
<xwiki.jacoco.instructionRatio>0.14</xwiki.jacoco.instructionRatio>
<!-- Revapi skipped because it's check in the legacy module -->
<xwiki.revapi.skip>true</xwiki.revapi.skip>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
org.xwiki.commons:xwiki-commons-job
</xwiki.extension.features>
<xwiki.jacoco.instructionRatio>0.62</xwiki.jacoco.instructionRatio>
<!-- Revapi skipped because it's check in the legacy module -->
<xwiki.revapi.skip>true</xwiki.revapi.skip>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.xwiki.logging.tail.LoggerTail;

/**
* Default implementation of {@link JobStatusStorage}.
* Default implementation of {@link JobStatusStore}.
*
* @version $Id$
* @since 6.1M2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
org.xwiki.job.internal.DefaultJobContext
org.xwiki.job.internal.DefaultJobExecutor
org.xwiki.job.internal.DefaultJobManager
org.xwiki.job.internal.DefaultJobManagerConfiguration
org.xwiki.job.internal.DefaultJobProgressManager
org.xwiki.job.internal.DefaultJobStatusStorage
org.xwiki.job.internal.DefaultJobStatusStore
org.xwiki.job.internal.JobStatusSerializer
org.xwiki.job.internal.script.safe.JobStatusScriptSafeProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<org.xwiki.job.internal.DefaultJobStatus>
<org.xwiki.job.DefaultJobStatus>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to modify the serialization in the XML files of the test, since the class is not present anymore in this module. I don't think it would have an impact for real world status serialization if the old class is available through the legacy module.

<state>FINISHED</state>
<request class="org.xwiki.job.DefaultRequest">
<id>
Expand Down Expand Up @@ -62,4 +62,4 @@
<null/>
</java.util.concurrent.ConcurrentLinkedQueue>
</logs>
</org.xwiki.job.internal.DefaultJobStatus>
</org.xwiki.job.DefaultJobStatus>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<org.xwiki.job.internal.DefaultJobStatus>
<org.xwiki.job.DefaultJobStatus>
<state>FINISHED</state>
<request class="org.xwiki.job.DefaultRequest">
<id>
Expand Down Expand Up @@ -61,4 +61,4 @@
<null/>
</java.util.concurrent.ConcurrentLinkedQueue>
</logs>
</org.xwiki.job.internal.DefaultJobStatus>
</org.xwiki.job.DefaultJobStatus>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<org.xwiki.job.internal.DefaultJobStatus>
<org.xwiki.job.DefaultJobStatus>
<state>FINISHED</state>
<request class="org.xwiki.job.DefaultRequest">
<id>
Expand Down Expand Up @@ -57,4 +57,4 @@
<null/>
</java.util.concurrent.ConcurrentLinkedQueue>
</logs>
</org.xwiki.job.internal.DefaultJobStatus>
</org.xwiki.job.DefaultJobStatus>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<org.xwiki.job.internal.DefaultJobStatus>
<org.xwiki.job.DefaultJobStatus>
<state>FINISHED</state>
<request class="org.xwiki.job.DefaultRequest">
<properties>
Expand Down Expand Up @@ -57,4 +57,4 @@
<null/>
</java.util.concurrent.ConcurrentLinkedQueue>
</logs>
</org.xwiki.job.internal.DefaultJobStatus>
</org.xwiki.job.DefaultJobStatus>
2 changes: 2 additions & 0 deletions xwiki-commons-core/xwiki-commons-legacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<module>xwiki-commons-legacy-classloader</module>
<module>xwiki-commons-legacy-component</module>
<module>xwiki-commons-legacy-configuration</module>
<module>xwiki-commons-legacy-extension</module>
<module>xwiki-commons-legacy-job</module>
<module>xwiki-commons-legacy-properties</module>
<module>xwiki-commons-legacy-velocity</module>
<module>xwiki-commons-legacy-velocity-tools</module>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<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>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-legacy</artifactId>
<version>15.7-SNAPSHOT</version>
</parent>
<artifactId>xwiki-commons-legacy-extension</artifactId>
<name>XWiki Commons - Legacy - Extension - Parent POM</name>
<packaging>pom</packaging>
<description>Legacy modules for xwiki-commons-extension-*</description>
<modules>
<module>xwiki-commons-legacy-extension-api</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<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>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-legacy-extension</artifactId>
<version>15.7-SNAPSHOT</version>
</parent>
<artifactId>xwiki-commons-legacy-extension-api</artifactId>
<name>XWiki Commons - Legacy - Extension - API</name>
<packaging>jar</packaging>
<description>Legacy module for xwiki-commons-extension-api</description>
<properties>
<xwiki.jacoco.instructionRatio>0.00</xwiki.jacoco.instructionRatio>
<!-- The features provided by this module so that it's found when resolving extension -->
<xwiki.extension.features>org.xwiki.commons:xwiki-commons-extension-api</xwiki.extension.features>
</properties>
<dependencies>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-extension-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-legacy-job-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.extension.job.history.internal;

import javax.inject.Named;
import javax.inject.Singleton;

import org.xwiki.component.annotation.Component;
import org.xwiki.extension.job.history.ReplayJobStatus;
import org.xwiki.job.Job;
import org.xwiki.job.event.JobStartedEvent;
import org.xwiki.job.internal.AbstractJobStatus;
import org.xwiki.observation.event.Event;

/**
* Legacy implementation of {@link ExtensionJobHistoryRecorder}.
*
* @version $Id$
* @since 15.7RC1
*/
@Component
@Named(ExtensionJobHistoryRecorder.NAME)
@Singleton
@Deprecated
public class LegacyExtensionJobHistoryRecorder extends ExtensionJobHistoryRecorder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me this class is actually useless.

{
@Override
public void onEvent(Event event, Object source, Object data)
{
boolean ignore = false;
if (event instanceof JobStartedEvent) {
Job job = (Job) source;
if (job.getStatus() instanceof org.xwiki.job.AbstractJobStatus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have used an aspect for injecting this condition check, but it felt easier to do it like that.

&& isSubJob((AbstractJobStatus<?>) job.getStatus())) {
// We record only the jobs that have been triggered explicitly or that are part of a replay.
ignore = true;
}
}
if (!ignore) {
super.onEvent(event, source, data);
}
}

private <T extends AbstractJobStatus<?>> boolean isSubJob(T jobStatus)
{
return jobStatus.isSubJob() && !(jobStatus.getParentJobStatus() instanceof ReplayJobStatus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
500:org.xwiki.extension.job.history.internal.LegacyExtensionJobHistoryRecorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<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>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-legacy</artifactId>
<version>15.7-SNAPSHOT</version>
</parent>
<artifactId>xwiki-commons-legacy-job</artifactId>
<name>XWiki Commons - Legacy - Job - Parent POM</name>
<packaging>pom</packaging>
<description>Legacy modules for xwiki-commons-job-*</description>
<modules>
<module>xwiki-commons-legacy-job-api</module>
<module>xwiki-commons-legacy-job-default</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<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>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-legacy-job</artifactId>
<version>15.7-SNAPSHOT</version>
</parent>
<artifactId>xwiki-commons-legacy-job-api</artifactId>
<name>XWiki Commons - Legacy - Job - API</name>
<packaging>jar</packaging>
<description>Legacy module for xwiki-commons-job-api</description>
<properties>
<xwiki.jacoco.instructionRatio>0.00</xwiki.jacoco.instructionRatio>
<!-- The features provided by this module so that it's found when resolving extension -->
<xwiki.extension.features>org.xwiki.commons:xwiki-commons-job-api</xwiki.extension.features>
</properties>
<dependencies>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-job-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Loading