You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by df...@apache.org on 2004/06/03 16:53:15 UTC
cvs commit: jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/util StoreHelper.java
dflorey 2004/06/03 07:53:15
Modified: proposals/projector/src/java/org/apache/slide/projector
SystemContext.java HttpContext.java
proposals/projector/src/java/org/apache/slide/projector/engine
ParameterConfiguration.java Process.java
ProcessorManager.java Step.java
proposals/projector/src/java/org/apache/slide/projector/application
ApplicationManager.java Application.java
proposals/projector/src/java/org/apache/slide/projector/processor/form
Test.java FormGenerator.java
proposals/projector/src/java/org/apache/slide/projector/processor/table
TablePager.java
proposals/projector/src/java/org/apache/slide/projector/util
StoreHelper.java
Added: proposals/projector/src/java/org/apache/slide/projector/application
Dependency.java
Log:
Added initial version of application dependency management.
This will allow proper installation order of different applications that rely on each other.
Some minor fixes.
Revision Changes Path
1.2 +1 -2 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/SystemContext.java
Index: SystemContext.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/SystemContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SystemContext.java 24 May 2004 14:00:36 -0000 1.1
+++ SystemContext.java 3 Jun 2004 14:53:14 -0000 1.2
@@ -8,8 +8,7 @@
import org.apache.slide.projector.store.RepositoryStore;
public class SystemContext extends AbstractContext {
- private final static String BOOKMARK = "_bookmark_";
- private final static String FORM_MAP = "_form_map_";
+ protected final static String BOOKMARK = "_bookmark_";
private Cache contextStore = new Cache();
private RepositoryStore repositoryStore = new RepositoryStore(this);
1.4 +10 -0 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/HttpContext.java
Index: HttpContext.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/HttpContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HttpContext.java 2 Jun 2004 15:35:39 -0000 1.3
+++ HttpContext.java 3 Jun 2004 14:53:14 -0000 1.4
@@ -1,5 +1,7 @@
package org.apache.slide.projector;
+import java.io.IOException;
+
import org.apache.commons.httpclient.Credentials;
import org.apache.slide.projector.store.*;
import org.apache.slide.projector.value.StreamableValue;
@@ -78,5 +80,13 @@
public StreamableValue getPresentableResource() {
return resource;
+ }
+
+ public void setBookmark(URI processor) throws IOException {
+ sessionStore.put(BOOKMARK, processor);
+ }
+
+ public URI getBookmark() throws IOException {
+ return (URI)sessionStore.get(BOOKMARK);
}
}
1.6 +3 -3 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ParameterConfiguration.java
Index: ParameterConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ParameterConfiguration.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ParameterConfiguration.java 2 Jun 2004 13:58:53 -0000 1.5
+++ ParameterConfiguration.java 3 Jun 2004 14:53:14 -0000 1.6
@@ -165,12 +165,12 @@
String processor = element.getAttributeValue("processor");
resultKey = element.getAttributeValue("result");
String storeName = element.getAttributeValue("store");
- if ( storeName != null ) {
- store = StoreHelper.getStoreByName(storeName);
+ store = StoreHelper.getStoreByName(storeName);
+ storeKey = element.getAttributeValue("key");
+ if ( storeKey != null ) {
storeUsed = true;
}
domain = element.getAttributeValue("domain");
- storeKey = element.getAttributeValue("key");
value = element.getTextTrim();
processorUri = ( processor == null ? null : new URIValue(processor) );
}
1.10 +2 -2 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/Process.java
Index: Process.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/Process.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Process.java 2 Jun 2004 13:58:53 -0000 1.9
+++ Process.java 3 Jun 2004 14:53:14 -0000 1.10
@@ -133,7 +133,7 @@
Result stepResult = null; // The result of the last executed step
Step step; // The current step
do {
- logger.log(Level.INFO, "Processing step: " + nextStep);
+ logger.log(Level.INFO, "Processing "+processorUri+", step=" + nextStep);
context.setStep(nextStep); // Remember current step in context
step = (Step)steps.get(nextStep);
if (step == null) throw new ProcessException(new ErrorMessage("stepNotFound", new String[]{nextStep}));
@@ -154,7 +154,7 @@
Scheduler.getInstance().addJob(step.getExpression(), step.getProcessorURI(), processorParameters, step.repeat(), step.isPersistent());
stepResult = new Result(OK);
}
- nextStep = routeState(step, result.getState());
+ nextStep = routeState(step, stepResult.getState());
} catch (Exception e) {
nextStep = routeException(step, e);
}
1.14 +10 -9 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ProcessorManager.java
Index: ProcessorManager.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ProcessorManager.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ProcessorManager.java 1 Jun 2004 14:48:42 -0000 1.13
+++ ProcessorManager.java 3 Jun 2004 14:53:14 -0000 1.14
@@ -34,9 +34,9 @@
* or was updated.
*/
public class ProcessorManager implements ApplicationListener, Subscriber {
- public final static URI BINARY = new URIValue("/image");
- public final static URI LOCALE_RESOLVER = new URIValue("/localeResolver");
- public final static URI URL = new URIValue("/url");
+ public final static URI BINARY = new URIValue("image");
+ public final static URI LOCALE_RESOLVER = new URIValue("localeResolver");
+ public final static URI URL = new URIValue("url");
private final static Logger logger = Logger.getLogger(ProcessorManager.class.getName());
private final static String PROCESSOR_CONFIG = "processors.xml";
@@ -135,7 +135,8 @@
}
public void notify(URI uri, Map information) {
- update((URI)configurationToApplication.get(uri), new URIValue(uri.toString().substring(Constants.REPOSITORY_DOMAIN.length()+1)));
+ uri = new URIValue(uri.toString().substring(Constants.REPOSITORY_DOMAIN.length()));
+ update((URI)configurationToApplication.get(uri), uri);
}
public Processor getProcessor(URI uri) throws ProcessException {
@@ -268,7 +269,7 @@
String smallIcon = attributes.getValue("small-icon");
String largeIcon = attributes.getValue("large-icon");
String clazz = attributes.getValue("class");
- String page = attributes.getValue("page");
+ String bookmark = attributes.getValue("bookmark");
Processor processor = (Processor)processorMap.get(uri);
ProcessorDescriptor processorDescriptor = (ProcessorDescriptor)processorDescriptors.get(uri);
try {
@@ -310,10 +311,10 @@
processorDescriptor.setLargeIcon(largeIconUri);
modified = true;
}
- if ( page != null ) {
- boolean bookmark = Boolean.valueOf(page).booleanValue();
- if ( processorDescriptor.isBookmark() != bookmark ) {
- processorDescriptor.setBookmark(bookmark);
+ if ( bookmark != null ) {
+ boolean isBookmark = Boolean.valueOf(bookmark).booleanValue();
+ if ( processorDescriptor.isBookmark() != isBookmark ) {
+ processorDescriptor.setBookmark(isBookmark);
modified = true;
}
}
1.5 +1 -1 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/Step.java
Index: Step.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/Step.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Step.java 1 Jun 2004 14:48:42 -0000 1.4
+++ Step.java 3 Jun 2004 14:53:14 -0000 1.5
@@ -101,7 +101,7 @@
boolean presentableResult = ConversionHelpers.getBoolean(saveElement.getAttributeValue("presentable"), false);
ResultConfiguration resultConfiguration;
if (resultStore == null) {
- resultConfiguration = new ResultConfiguration(resultName, Store.NONE, resultDomain, resultName, presentableResult, timeout);
+ resultConfiguration = new ResultConfiguration(resultName, Store.NONE, resultDomain, resultKey, presentableResult, timeout);
} else {
resultConfiguration = new ResultConfiguration(resultName, resultStore, resultDomain, resultKey, presentableResult, timeout);
}
1.6 +73 -9 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/ApplicationManager.java
Index: ApplicationManager.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/ApplicationManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ApplicationManager.java 2 Jun 2004 13:58:53 -0000 1.5
+++ ApplicationManager.java 3 Jun 2004 14:53:14 -0000 1.6
@@ -62,6 +62,8 @@
private synchronized void installApplications() {
Value[] applicationUris;
+ List applicationsToInstall = new ArrayList();
+ List applicationsToRemove = new ArrayList();
try {
List removedApplications = new ArrayList();
removedApplications.addAll(installedApplications.keySet());
@@ -76,7 +78,9 @@
}
if ( !installedApplications.containsKey(applicationUri) ) {
Application installedApplication = parseApplication(new URIValue(applicationUri));
- if ( installedApplication != null ) install(installedApplication);
+ if ( installedApplication != null ) {
+ applicationsToInstall.add(installedApplication);
+ }
} else {
logger.log(Level.INFO, "Application '"+applicationUri+"' already installed");
removedApplications.remove(applicationUri);
@@ -84,7 +88,13 @@
}
for ( Iterator i = removedApplications.iterator(); i.hasNext(); ) {
Application removedApplication = (Application)installedApplications.get((URI)i.next());
- uninstall(removedApplication);
+ applicationsToRemove.add(removedApplication);
+ }
+ // install applications sorted by application dependencies
+ List sortedApplications = sortApplications(applicationsToInstall);
+ for ( Iterator i = sortedApplications.iterator(); i.hasNext(); ) {
+ Application application = (Application)i.next();
+ install(application);
}
} catch (IOException e) {
logger.log(Level.SEVERE, "Could not determine installed applications!", e);
@@ -98,6 +108,53 @@
return applicationManager;
}
+ private List sortApplications(List applicationsToInstall) {
+ List sortedApplications = new ArrayList();
+ for ( Iterator i = applicationsToInstall.iterator(); i.hasNext(); ) {
+ Application application = (Application)i.next();
+ if ( !sortedApplications.contains(application) ) {
+ logger.log(Level.INFO, "Try to install '"+application.getName()+"'");
+ addRequiredApplicationsFirst(sortedApplications, applicationsToInstall, application);
+ }
+ }
+ return sortedApplications;
+ }
+
+ private void addRequiredApplicationsFirst(List sortedApplications, List applicationsToInstall, Application application) {
+ // FIXME: Check application versions
+ logger.log(Level.INFO, "Checking for dependencies...");
+ for ( Iterator i = application.getDependencies().iterator(); i.hasNext(); ) {
+ Dependency dependency = (Dependency)i.next();
+ logger.log(Level.INFO, "Dependency on application '"+dependency.getRequiredApplication()+"' found!");
+ Application requiredApplication = getApplicationByName(applicationsToInstall, dependency.getRequiredApplication());
+ if ( requiredApplication == null ) {
+ // check if application is already installed
+ requiredApplication = getApplicationByName(installedApplications.entrySet(), dependency.getRequiredApplication());
+ if ( requiredApplication == null ) {
+ // FIXME: Throw exception and abort startup
+ logger.log(Level.SEVERE, "Required application '"+dependency.getRequiredApplication()+"' not found!");
+ }
+ } else {
+ logger.log(Level.INFO, "Required application '"+requiredApplication.getName()+"' not installed but available, so install it first");
+ addRequiredApplicationsFirst(sortedApplications, applicationsToInstall, requiredApplication);
+ }
+ }
+ logger.log(Level.INFO, "Adding '"+application.getName()+"' to installation process");
+ if ( !sortedApplications.contains(application) ) {
+ sortedApplications.add(application);
+ }
+ }
+
+ private Application getApplicationByName(Collection applications, String name) {
+ for ( Iterator i = applications.iterator(); i.hasNext(); ) {
+ Application application = (Application)i.next();
+ if ( application.getName().equals(name)) {
+ return application;
+ }
+ }
+ return null;
+ }
+
private Application parseApplication(URI applicationUri) {
try {
SimpleImporter importer = new SimpleImporter();
@@ -215,13 +272,20 @@
public void startElement(SimplePath path, String name, AttributesImpl attributes, String leadingCDdata) {
if (path.matches("application")) {
application = new Application(applicationUri);
- } else if ( path.matches("display-name") ) {
+ } else if ( path.matches("application/name") ) {
+ application.setName(leadingCDdata);
+ } else if ( path.matches("application/display-name") ) {
application.setDisplayName(leadingCDdata);
- } else if ( path.matches("vendor") ) {
+ } else if ( path.matches("application/vendor") ) {
application.setVendor(leadingCDdata);
- } else if ( path.matches("description") ) {
+ } else if ( path.matches("application/description") ) {
application.setDescription(leadingCDdata);
- } else if ( path.matches("resource-types/resource-type") ) {
+ } else if ( path.matches("application/version") ) {
+ application.setVersion(leadingCDdata);
+ } else if ( path.matches("application/dependencies/requires") ) {
+ Dependency dependency = new Dependency(attributes.getValue("application"), attributes.getValue("version"));
+ application.addDependency(dependency);
+ } else if ( path.matches("application/resource-types/resource-type") ) {
String resourceTypeName = attributes.getValue("name");
String clazz = attributes.getValue("class");
try {
@@ -231,12 +295,12 @@
} catch (Exception e) {
logger.log(Level.SEVERE, "Descriptor factory " + clazz + " could not loaded!", e);
}
- } else if ( path.matches("content/processors") ) {
+ } else if ( path.matches("application/content/processors") ) {
String uri = attributes.getValue("uri");
application.addContent(Application.PROCESSORS, new URIValue(applicationUri+attributes.getValue("uri")));
- } else if ( path.matches("content/messages") ) {
+ } else if ( path.matches("application/content/messages") ) {
application.addContent(Application.MESSAGES, new URIValue(applicationUri+attributes.getValue("uri")));
- } else if ( path.matches("content/jobs") ) {
+ } else if ( path.matches("application/content/jobs") ) {
application.addContent(Application.JOBS, new URIValue(applicationUri+attributes.getValue("uri")));
}
}
1.2 +34 -2 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/Application.java
Index: Application.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/Application.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Application.java 24 May 2004 13:52:44 -0000 1.1
+++ Application.java 3 Jun 2004 14:53:14 -0000 1.2
@@ -13,13 +13,23 @@
public final static String JOBS = "jobs";
private URI uri;
- private String displayName, vendor, description;
+ private String name, displayName, vendor, description;
private Map content = new HashMap();
-
+ private List dependecies = new ArrayList();
+ private String version;
+
Application(URI applicationUri) {
this.uri = applicationUri;
}
+ public List getDependencies() {
+ return dependecies;
+ }
+
+ public void addDependency(Dependency dependency) {
+ dependecies.add(dependency);
+ }
+
public URI getUri() {
return uri;
}
@@ -63,5 +73,27 @@
Map getContent() {
return content;
+ }
+
+ String getVersion() {
+ return version;
+ }
+
+ void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ String getName() {
+ return name;
+ }
+
+ /**
+ * @param name The name to set.
+ */
+ void setName(String name) {
+ this.name = name;
}
}
1.1 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/Dependency.java
Index: Dependency.java
===================================================================
/*
*
* ====================================================================
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.slide.projector.application;
/**
* @author dflorey
*/
public class Dependency {
String requiredApplication;
String requiredVersion;
public Dependency(String requiredApplication, String requiredVersion) {
this.requiredApplication = requiredApplication;
this.requiredVersion = requiredVersion;
}
/**
* @return Returns the requiredApplication.
*/
public String getRequiredApplication() {
return requiredApplication;
}
/**
* @return Returns the requiredVersion.
*/
public String getRequiredVersion() {
return requiredVersion;
}
}
1.5 +9 -3 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/form/Test.java
Index: Test.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/form/Test.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Test.java 1 Jun 2004 07:49:55 -0000 1.4
+++ Test.java 3 Jun 2004 14:53:14 -0000 1.5
@@ -7,6 +7,7 @@
import org.apache.slide.projector.Context;
import org.apache.slide.projector.Information;
+import org.apache.slide.projector.ProcessException;
import org.apache.slide.projector.Processor;
import org.apache.slide.projector.Result;
import org.apache.slide.projector.Store;
@@ -16,6 +17,7 @@
import org.apache.slide.projector.descriptor.URIValueDescriptor;
import org.apache.slide.projector.engine.Process;
import org.apache.slide.projector.engine.ProcessorManager;
+import org.apache.slide.projector.i18n.ErrorMessage;
import org.apache.slide.projector.i18n.ParameterMessage;
import org.apache.slide.projector.store.FormStore;
import org.apache.slide.projector.util.ProcessorHelper;
@@ -27,8 +29,8 @@
import org.apache.slide.projector.value.Value;
public class Test implements Processor {
- private final static URI FORM_PROCESSOR = new URIValue("/formGenerator");
- private final static URI RESULT_RENDERER = new URIValue("/result");
+ private final static URI FORM_PROCESSOR = new URIValue("formGenerator");
+ private final static URI RESULT_RENDERER = new URIValue("formResult");
private final static String PROCESSOR = "processor";
private final static String FORM_STEP = "form";
@@ -40,10 +42,14 @@
};
public Result process(Map parameter, Context context) throws Exception {
- context.setBookmark(ProcessorManager.getInstance().getURI(this));
+ URI processorUri = ProcessorManager.getInstance().getURI(this);
+ context.setBookmark(processorUri);
Value uri = (Value)parameter.get(PROCESSOR);
if ( uri == null || uri == NullValue.NULL ) {
uri = (URI)context.getStore(Store.SESSION).get(PROCESSOR);
+ }
+ if ( uri == null ) {
+ throw new ProcessException(new ErrorMessage("test/noProcessorSpecified"));
}
context.setProcess((URI)uri);
context.getStore(Store.SESSION).put(PROCESSOR, uri);
1.10 +2 -2 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/form/FormGenerator.java
Index: FormGenerator.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/form/FormGenerator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FormGenerator.java 1 Jun 2004 07:49:55 -0000 1.9
+++ FormGenerator.java 3 Jun 2004 14:53:14 -0000 1.10
@@ -27,7 +27,7 @@
protected final static URI COMBOBOX = new URIValue("combobox");
protected final static URI CHECKBOX = new URIValue("checkbox");
protected final static URI ERRORS_TABLE = new URIValue("errors");
- protected final static URI TRIGGER_URI = new URIValue("textbutton");
+ protected final static URI TRIGGER_URI = new URIValue("textTrigger");
protected final static URI DEFAULT_TRIGGER_IMAGE = new URIValue("/files/contelligent/images/ok.gif");
protected final static URI DEFAULT_CONTROL_CONTAINER = new URIValue("bigControl");
protected final static URI DEFAULT_TRIGGER_CONTAINER = new URIValue("triggerContainer");
1.3 +2 -2 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/table/TablePager.java
Index: TablePager.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/table/TablePager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TablePager.java 1 Jun 2004 07:49:58 -0000 1.2
+++ TablePager.java 3 Jun 2004 14:53:15 -0000 1.3
@@ -28,7 +28,7 @@
public final static String FAILED = "failed";
- protected final static String HANDLER = "/tableHandler";
+ protected final static String HANDLER = "tableHandler";
protected final static String HANDLER_URL = "handler";
protected final static String PRE_FRAGMENT = "pre";
1.4 +0 -1 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/util/StoreHelper.java
Index: StoreHelper.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/util/StoreHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StoreHelper.java 1 Jun 2004 07:49:57 -0000 1.3
+++ StoreHelper.java 3 Jun 2004 14:53:15 -0000 1.4
@@ -44,7 +44,6 @@
for ( int i = 0; i < Store.stores.length; i++ ) {
if ( Store.stores[i].equals(store) ) return i;
}
- logger.log(Level.SEVERE, "Invalid store name = '"+store+"'");
return Store.NONE;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org