forked from comixed/comixed
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the Python plugin environment [comixed#26]
* Python sources are packaged in the JAR file.
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 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
71 changes: 71 additions & 0 deletions
71
comixed-plugins/src/main/java/org/comixed/plugins/interpreters/PythonPluginInterpreter.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,71 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2020, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
package org.comixed.plugins.interpreters; | ||
|
||
import lombok.extern.log4j.Log4j2; | ||
import org.comixed.plugins.PluginException; | ||
import org.comixed.plugins.model.Plugin; | ||
import org.comixed.service.comic.ComicService; | ||
import org.comixed.service.comic.PageService; | ||
import org.python.util.PythonInterpreter; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* <code>PythonPluginInterpreter</code> defines a type of {@link PluginInterpreter} that executes | ||
* Python code. | ||
* | ||
* @author Darryl L. Pierce | ||
*/ | ||
@Component | ||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) | ||
@Log4j2 | ||
public class PythonPluginInterpreter extends AbstractPluginInterpreter { | ||
@Autowired private ComicService comicService; | ||
@Autowired private PageService pageService; | ||
|
||
private PythonInterpreter interpreter; | ||
|
||
@Override | ||
public void initialize() throws PluginException { | ||
super.initialize(); | ||
|
||
log.debug("Initializing Python runtime environment"); | ||
this.interpreter = new PythonInterpreter(); | ||
|
||
this.loadRuntimeObjects(); | ||
} | ||
|
||
private void loadRuntimeObjects() { | ||
log.debug("Loading ComiXed Python runtime objects"); | ||
this.interpreter.set("comicService", this.comicService); | ||
this.interpreter.set("pageService", this.pageService); | ||
this.interpreter.set("logger", this.log); | ||
} | ||
|
||
@Override | ||
public void start(Plugin plugin) throws PluginException {} | ||
|
||
@Override | ||
public void finish() throws PluginException { | ||
super.finish(); | ||
} | ||
} |
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,18 @@ | ||
# ComiXed - A digital comic book library management application. | ||
# Copyright (C) 2020, The ComiXed Project | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses> | ||
|
||
import org.comixed.service.comic.ComicService as ComicService | ||
|
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