Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various refactorings in support of [IMMUTANT-143]
Including: * JobScheduler is now an MSC service instead of being created ad hoc * application initialization now happens asynchronously, but in an MSC service so it will still complete before the deployment is considered complete
- Loading branch information
Showing
14 changed files
with
274 additions
and
150 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
modules/core/src/main/java/org/immutant/core/ApplicationInitializer.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,73 @@ | ||
/* | ||
* Copyright 2008-2013 Red Hat, Inc, and individual contributors. | ||
* | ||
* 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.immutant.core; | ||
|
||
import org.immutant.runtime.ClojureRuntime; | ||
import org.jboss.msc.inject.Injector; | ||
import org.jboss.msc.service.StartContext; | ||
import org.jboss.msc.service.StopContext; | ||
import org.jboss.msc.value.InjectedValue; | ||
import org.projectodd.polyglot.core.AsyncService; | ||
|
||
public class ApplicationInitializer<Void> extends AsyncService<Void> { | ||
|
||
public ApplicationInitializer(String fullAppConfig, | ||
String leinProject, | ||
ClojureMetaData metaData) { | ||
this.fullAppConfig = fullAppConfig; | ||
this.leinProject = leinProject; | ||
this.metaData = metaData; | ||
} | ||
|
||
@Override | ||
public void startAsync(StartContext context) throws Exception { | ||
ClojureRuntime runtime = this.clojureRuntimeInjector.getValue(); | ||
Timer t = new Timer("setting app config"); | ||
runtime.invoke("immutant.runtime/set-app-config", | ||
this.fullAppConfig, | ||
this.leinProject); | ||
t.done(); | ||
t = new Timer("initializing app"); | ||
runtime.invoke("immutant.runtime/initialize", | ||
this.metaData.getInitFunction(), | ||
this.metaData.getConfig()); | ||
t.done(); | ||
} | ||
|
||
@Override | ||
public Void getValue() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public synchronized void stop(StopContext context) { | ||
} | ||
|
||
public Injector<ClojureRuntime> getClojureRuntimeInjector() { | ||
return this.clojureRuntimeInjector; | ||
} | ||
|
||
private String fullAppConfig; | ||
private String leinProject; | ||
private ClojureMetaData metaData; | ||
|
||
private InjectedValue<ClojureRuntime> clojureRuntimeInjector = new InjectedValue<ClojureRuntime>(); | ||
|
||
} |
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
60 changes: 0 additions & 60 deletions
60
modules/core/src/main/java/org/immutant/core/processors/ApplicationInitializer.java
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
modules/core/src/main/java/org/immutant/core/processors/ApplicationInitializerInstaller.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,69 @@ | ||
/* | ||
* Copyright 2008-2013 Red Hat, Inc, and individual contributors. | ||
* | ||
* 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.immutant.core.processors; | ||
|
||
import org.immutant.core.ApplicationInitializer; | ||
import org.immutant.core.ClojureMetaData; | ||
import org.immutant.core.as.CoreServices; | ||
import org.jboss.as.server.deployment.DeploymentPhaseContext; | ||
import org.jboss.as.server.deployment.DeploymentUnit; | ||
import org.jboss.as.server.deployment.DeploymentUnitProcessingException; | ||
import org.jboss.as.server.deployment.DeploymentUnitProcessor; | ||
import org.jboss.logging.Logger; | ||
import org.jboss.msc.service.ServiceController.Mode; | ||
|
||
public class ApplicationInitializerInstaller implements DeploymentUnitProcessor { | ||
|
||
public ApplicationInitializerInstaller() { | ||
} | ||
|
||
/** | ||
* @param phaseContext | ||
* | ||
* @throws DeploymentUnitProcessingException | ||
*/ | ||
@Override | ||
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { | ||
DeploymentUnit unit = phaseContext.getDeploymentUnit(); | ||
ClojureMetaData metaData = unit.getAttachment(ClojureMetaData.ATTACHMENT_KEY); | ||
|
||
if (metaData == null) { | ||
return; | ||
} | ||
|
||
ApplicationInitializer service = | ||
new ApplicationInitializer(unit.getAttachment(ClojureMetaData.FULL_APP_CONFIG), | ||
unit.getAttachment(ClojureMetaData.LEIN_PROJECT), | ||
metaData); | ||
|
||
phaseContext.getServiceTarget() | ||
.addService(CoreServices.appInitializer(unit), service) | ||
.addDependency(CoreServices.runtime(unit), service.getClojureRuntimeInjector()) | ||
.setInitialMode(Mode.ACTIVE) | ||
.install(); | ||
} | ||
|
||
@Override | ||
public void undeploy(DeploymentUnit context) { | ||
|
||
} | ||
|
||
static final Logger log = Logger.getLogger( "org.immutant.core" ); | ||
} |
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
Oops, something went wrong.