From 38d30cd4f69178cef983ec13262a6f02826a9a45 Mon Sep 17 00:00:00 2001 From: abranson Date: Wed, 28 Sep 2011 14:19:34 +0200 Subject: Schema and resource --- source/com/c2kernel/utils/Resource.java | 39 ++++++++------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) (limited to 'source/com/c2kernel') diff --git a/source/com/c2kernel/utils/Resource.java b/source/com/c2kernel/utils/Resource.java index 361549d..ba2f71a 100644 --- a/source/com/c2kernel/utils/Resource.java +++ b/source/com/c2kernel/utils/Resource.java @@ -3,6 +3,7 @@ package com.c2kernel.utils; //Java import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.Hashtable; import javax.swing.ImageIcon; @@ -17,13 +18,9 @@ import com.c2kernel.common.ObjectNotFoundException; public class Resource { static private Hashtable txtCache = new Hashtable(); static private Hashtable imgCache = new Hashtable(); - static private URL baseURL = null; - static private URL domainBaseURL = null; - static private URL importURL = null; + static private URL baseURL = getURLorResURL("com/c2kernel/utils/resources/"); + static private ArrayList domainBaseURL = new ArrayList(); static public ImageIcon nullImg = new ImageIcon(new byte[] { 0 }); - static { - setKernelBaseURL("com/c2kernel/utils/resources/"); - } /* * Kernel Resource URL section @@ -32,10 +29,6 @@ public class Resource { baseURL = getURLorResURL(newBaseURL); } - public static void setKernelBaseURL(URL newBaseURL) { - baseURL = newBaseURL; - } - public static URL getKernelBaseURL() { return baseURL; } @@ -43,19 +36,20 @@ public class Resource { static public URL getKernelResourceURL(String resName) throws MalformedURLException { return new URL(baseURL, resName); } + /* * Domain Resource URL section */ - public static void setDomainBaseURL(URL newBaseURL) { - domainBaseURL = newBaseURL; + public static void addDomainBaseURL(URL newBaseURL) { + domainBaseURL.add(newBaseURL); } - public static void setDomainBaseURL(String newBaseURL) { - domainBaseURL = getURLorResURL(newBaseURL); + public static void addDomainBaseURL(String newBaseURL) { + addDomainBaseURL(getURLorResURL(newBaseURL)); } - public static URL getDomainBaseURL() { + public static ArrayList getDomainBaseURL() { return domainBaseURL; } @@ -153,21 +147,6 @@ public class Resource { return newImg; } - - /** - * Retrieves the stored import URL - * @return - */ - public static URL getImportURL() { - return importURL; - } - - /** - * @param url - */ - public static void setImportURL(URL url) { - importURL = url; - } static public String getDomainVersion() { try { return FileStringUtility.url2String(getDomainResourceURL("version.txt")); -- cgit v1.2.3 From 684e01bb190c7d0b95347b732aeb3cdeda4740d7 Mon Sep 17 00:00:00 2001 From: abranson Date: Tue, 18 Oct 2011 17:00:33 +0200 Subject: Module support --- build.xml | 2 +- changelog | 15 +- resources/boot/CA/CompositeActivityFactory.xml | 108 -------- resources/boot/CA/ElementaryActivityFactory.xml | 108 -------- resources/boot/CA/ManageCompositeActDef.xml | 219 --------------- resources/boot/CA/ManageElementaryActDef.xml | 219 --------------- resources/boot/CA/ManageSchema.xml | 218 --------------- resources/boot/CA/ManageScript.xml | 219 --------------- resources/boot/CA/SchemaFactory.xml | 108 -------- resources/boot/CA/ScriptFactory.xml | 108 -------- resources/boot/EA/AssignNewVersionFromLast.xml | 20 -- resources/boot/EA/CreateNewLocalObjectDef.xml | 19 -- resources/boot/EA/EditActivityDef.xml | 19 -- resources/boot/EA/EditProperties.xml | 20 -- resources/boot/EA/EditSchema.xml | 19 -- resources/boot/EA/EditScriptDefinition.xml | 19 -- resources/boot/OD/CompositeActivityDef.xml | 186 ------------- resources/boot/OD/CompositeActivityDef.xsd | 186 +++++++++++++ resources/boot/OD/CristalModule.xsd | 149 ---------- resources/boot/OD/ElementaryActivityDef.xml | 29 -- resources/boot/OD/ElementaryActivityDef.xsd | 29 ++ resources/boot/OD/Module.xsd | 141 ++++++++++ resources/boot/OD/New.xml | 3 - resources/boot/OD/NewAgent.xml | 20 -- resources/boot/OD/NewAgent.xsd | 20 ++ resources/boot/OD/NewItem.xml | 73 ----- resources/boot/OD/NewItem.xsd | 73 +++++ resources/boot/OD/NewLocalObjectDef.xml | 20 -- resources/boot/OD/PredefinedStepOutcome.xml | 13 - resources/boot/OD/PredefinedStepOutcome.xsd | 13 + resources/boot/OD/PropertyDescription.xml | 36 --- resources/boot/OD/PropertyDescription.xsd | 36 +++ resources/boot/OD/Schema.xml | 4 - resources/boot/OD/Schema.xsd | 4 + resources/boot/OD/Script.xml | 38 --- resources/boot/OD/Script.xsd | 38 +++ .../boot/SC/CreateNewNumberedVersionFromLast.xml | 39 --- resources/boot/SC/LocalObjectDefCreator.xml | 57 ---- resources/boot/SC/New.xml | 13 - resources/boot/allbootitems.txt | 28 +- resources/boot/factory/CA.xml | 8 - resources/boot/factory/EA.xml | 8 - resources/boot/factory/OD.xml | 8 - resources/boot/factory/SC.xml | 8 - .../images/typeicons/localobjectfactory_16.png | Bin 916 -> 0 bytes .../images/typeicons/localobjectfactory_32.png | Bin 2084 -> 0 bytes resources/mapFiles/ModuleMap.xml | 27 ++ resources/mapFiles/index | 2 +- resources/textFiles/version.txt | 2 +- .../com/c2kernel/collection/AggregationMember.java | 2 +- source/com/c2kernel/events/History.java | 11 +- source/com/c2kernel/graph/view/EditorToolBar.java | 14 +- source/com/c2kernel/graph/view/GraphPanel.java | 2 +- source/com/c2kernel/gui/Console.java | 4 +- source/com/c2kernel/gui/DynamicTreeBuilder.java | 8 +- source/com/c2kernel/gui/EntityDetails.java | 2 +- source/com/c2kernel/gui/EntityFinder.java | 8 +- source/com/c2kernel/gui/LoginBox.java | 6 +- source/com/c2kernel/gui/Main.java | 5 +- source/com/c2kernel/gui/MainFrame.java | 6 +- source/com/c2kernel/gui/MenuBuilder.java | 22 +- source/com/c2kernel/gui/data/Node.java | 6 +- source/com/c2kernel/gui/tabs/EntityTabPane.java | 8 +- source/com/c2kernel/gui/tabs/WorkflowPane.java | 8 +- .../gui/tabs/collection/AggregationView.java | 4 +- .../lifecycle/chooser/ActivityChooser.java | 2 +- .../lifecycle/gui/model/WfVertexDefFactory.java | 4 +- .../gui/view/CompActDefOutcomeHandler.java | 4 +- .../com/c2kernel/lifecycle/instance/Activity.java | 2 +- .../instance/gui/model/WfVertexFactory.java | 4 +- .../predefined/entitycreation/CreateNewAgent.java | 6 +- .../predefined/entitycreation/NewItem.java | 1 + source/com/c2kernel/lookup/LDAPLookup.java | 10 +- source/com/c2kernel/persistency/RemoteMap.java | 2 + source/com/c2kernel/process/AbstractMain.java | 44 --- source/com/c2kernel/process/Bootstrap.java | 156 +++-------- source/com/c2kernel/process/Gateway.java | 77 +++--- source/com/c2kernel/process/Module.java | 303 +++++++++++++++++++++ source/com/c2kernel/process/ModuleManager.java | 81 ++++++ source/com/c2kernel/process/StandardServer.java | 5 +- source/com/c2kernel/process/UserCodeProcess.java | 6 +- source/com/c2kernel/scripting/ErrorInfo.java | 5 + source/com/c2kernel/scripting/Script.java | 11 +- source/com/c2kernel/scripting/ScriptConsole.java | 6 +- source/com/c2kernel/utils/CastorArrayList.java | 2 +- source/com/c2kernel/utils/Resource.java | 148 +++++----- 86 files changed, 1235 insertions(+), 2511 deletions(-) delete mode 100755 resources/boot/CA/CompositeActivityFactory.xml delete mode 100755 resources/boot/CA/ElementaryActivityFactory.xml delete mode 100755 resources/boot/CA/ManageCompositeActDef.xml delete mode 100755 resources/boot/CA/ManageElementaryActDef.xml delete mode 100755 resources/boot/CA/ManageSchema.xml delete mode 100755 resources/boot/CA/ManageScript.xml delete mode 100755 resources/boot/CA/SchemaFactory.xml delete mode 100755 resources/boot/CA/ScriptFactory.xml delete mode 100755 resources/boot/EA/AssignNewVersionFromLast.xml delete mode 100755 resources/boot/EA/CreateNewLocalObjectDef.xml delete mode 100755 resources/boot/EA/EditActivityDef.xml delete mode 100755 resources/boot/EA/EditProperties.xml delete mode 100755 resources/boot/EA/EditSchema.xml delete mode 100755 resources/boot/EA/EditScriptDefinition.xml delete mode 100755 resources/boot/OD/CompositeActivityDef.xml create mode 100644 resources/boot/OD/CompositeActivityDef.xsd delete mode 100644 resources/boot/OD/CristalModule.xsd delete mode 100755 resources/boot/OD/ElementaryActivityDef.xml create mode 100644 resources/boot/OD/ElementaryActivityDef.xsd create mode 100644 resources/boot/OD/Module.xsd delete mode 100755 resources/boot/OD/New.xml delete mode 100755 resources/boot/OD/NewAgent.xml create mode 100644 resources/boot/OD/NewAgent.xsd delete mode 100755 resources/boot/OD/NewItem.xml create mode 100644 resources/boot/OD/NewItem.xsd delete mode 100755 resources/boot/OD/NewLocalObjectDef.xml delete mode 100755 resources/boot/OD/PredefinedStepOutcome.xml create mode 100644 resources/boot/OD/PredefinedStepOutcome.xsd delete mode 100755 resources/boot/OD/PropertyDescription.xml create mode 100644 resources/boot/OD/PropertyDescription.xsd delete mode 100755 resources/boot/OD/Schema.xml create mode 100644 resources/boot/OD/Schema.xsd delete mode 100755 resources/boot/OD/Script.xml create mode 100644 resources/boot/OD/Script.xsd delete mode 100755 resources/boot/SC/CreateNewNumberedVersionFromLast.xml delete mode 100755 resources/boot/SC/LocalObjectDefCreator.xml delete mode 100755 resources/boot/SC/New.xml mode change 100755 => 100644 resources/boot/allbootitems.txt delete mode 100755 resources/boot/factory/CA.xml delete mode 100755 resources/boot/factory/EA.xml delete mode 100755 resources/boot/factory/OD.xml delete mode 100755 resources/boot/factory/SC.xml delete mode 100755 resources/images/typeicons/localobjectfactory_16.png delete mode 100755 resources/images/typeicons/localobjectfactory_32.png create mode 100644 resources/mapFiles/ModuleMap.xml mode change 100755 => 100644 resources/textFiles/version.txt create mode 100644 source/com/c2kernel/process/Module.java create mode 100644 source/com/c2kernel/process/ModuleManager.java (limited to 'source/com/c2kernel') diff --git a/build.xml b/build.xml index 81bfea3..4d86455 100644 --- a/build.xml +++ b/build.xml @@ -47,7 +47,7 @@ - + diff --git a/changelog b/changelog index 9bdb497..c728b02 100644 --- a/changelog +++ b/changelog @@ -1,9 +1,14 @@ -Build 6 - Module support -Build 5 - Java 1.6 Compliance -Build 4 - First GIT commit -- WF: Added 'AlwaysUseOutcome' activity property to require an outcome for every state change +Release 2.3 +----------- +Build 3 - Module support +- SYS: Cristal now supports multiple domain libraries concurrently - CRISTAL modules. Each declares its components in a module.xml in the root of its jar which can add config, resources, items and agents. Also scripts on startup/shutdown. +Build 2 - Java 1.6 Compliance +Build 1 - First GIT commit - SYS: Cleaned up some proxy methods. getContents() now calls storage directly. - SYS: Removed Orbacus. Use JDK ORB instead. Use JDK idlj compiler instead of Orbacus one. Remove all Orbacus tools. + +Release 2.2 +----------- Build 3 - Last CERN - GUI: Local object creating script now opens new desc when done. - LDAP: Optimised Path setting by String. @@ -52,7 +57,7 @@ Build 1 - SYS: Moved all API objects out of AbstractMain into the Gateway. AbstractMain is no longer required to initialise a kernel process. - SYS: Moved Gateway to process package. Moved LDAP init to process.Bootstrap - will be entry point for basic item creation -Changes for release 1.2 +Release 1.2 ----------------------- Build 22 - GUI: Multiple table row select when read only diff --git a/resources/boot/CA/CompositeActivityFactory.xml b/resources/boot/CA/CompositeActivityFactory.xml deleted file mode 100755 index 1a963cb..0000000 --- a/resources/boot/CA/CompositeActivityFactory.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - 9 - - - - - - - - - - - 7 - 12 - - - - - - - - - - - 13 - 7 - 9 - - - - - - - - - - - - - 12 - 13 - - - - - - - CreateNewLocalObjectDef - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CreateNewLocalObjectDef - diff --git a/resources/boot/CA/ElementaryActivityFactory.xml b/resources/boot/CA/ElementaryActivityFactory.xml deleted file mode 100755 index bf14607..0000000 --- a/resources/boot/CA/ElementaryActivityFactory.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - 9 - - - - - - - - - - - 7 - 12 - - - - - - - - - - - 13 - 7 - 9 - - - - - - - - - - - - - 12 - 13 - - - - - - - CreateNewLocalObjectDef - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CreateNewLocalObjectDef - diff --git a/resources/boot/CA/ManageCompositeActDef.xml b/resources/boot/CA/ManageCompositeActDef.xml deleted file mode 100755 index 9a48f1c..0000000 --- a/resources/boot/CA/ManageCompositeActDef.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - 19 - 20 - 21 - - - - - - - - - - - - - 17 - 20 - 18 - - - - - - - - - - - 16 - 17 - - - - - - - - - - - - 8 - 21 - - - - - - - - - - - 25 - 7 - 8 - - - - - - - - - - - - - 18 - 19 - - - - - - - AssignNewVersionFromLast - - - - - - - - 7 - 16 - 24 - - - - - - - - - - - 24 - 25 - - - - - - - EditActivityDef - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AssignNewVersionFromLast - EditActivityDef - diff --git a/resources/boot/CA/ManageElementaryActDef.xml b/resources/boot/CA/ManageElementaryActDef.xml deleted file mode 100755 index 1aa3840..0000000 --- a/resources/boot/CA/ManageElementaryActDef.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - 19 - 20 - 21 - - - - - - - - - - - - - 17 - 20 - 18 - - - - - - - - - - - 8 - 21 - - - - - - - - - - - 16 - 17 - - - - - - - - - - - - 25 - 7 - 8 - - - - - - - - - - - - - 7 - 16 - 24 - - - - - - - - - - - 18 - 19 - - - - - - - AssignNewVersionFromLast - - - - - - - - 24 - 25 - - - - - - - EditActivityDef - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AssignNewVersionFromLast - EditActivityDef - diff --git a/resources/boot/CA/ManageSchema.xml b/resources/boot/CA/ManageSchema.xml deleted file mode 100755 index da501e4..0000000 --- a/resources/boot/CA/ManageSchema.xml +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - - - - 19 - 20 - 21 - - - - - - - - - - - - - 17 - 20 - 18 - - - - - - - - - - - 16 - 17 - - - - - - - - - - - - 8 - 21 - - - - - - - - - - - 6 - 7 - 8 - - - - - - - - - - - - - 18 - 19 - - - - - - - AssignNewVersionFromLast - - - - - - - - 7 - 16 - 5 - - - - - - - - - - - 5 - 6 - - - - - - EditSchema - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AssignNewVersionFromLast - EditSchema - diff --git a/resources/boot/CA/ManageScript.xml b/resources/boot/CA/ManageScript.xml deleted file mode 100755 index f8100b0..0000000 --- a/resources/boot/CA/ManageScript.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - 24 - 25 - 26 - - - - - - - - - - - - - 21 - 22 - 23 - - - - - - - - - - - - - 18 - 25 - 20 - - - - - - - - - - - 17 - 23 - 19 - - - - - - - - - - - 17 - 18 - - - - - - - - - - - - 19 - 21 - - - - - - EditScriptDefinition - - - - - - - - 20 - 24 - - - - - - - AssignNewVersionFromLast - - - - - - - - 22 - 26 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EditScriptDefinition - AssignNewVersionFromLast - diff --git a/resources/boot/CA/SchemaFactory.xml b/resources/boot/CA/SchemaFactory.xml deleted file mode 100755 index aa903db..0000000 --- a/resources/boot/CA/SchemaFactory.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - 9 - - - - - - - - - - - 7 - 12 - - - - - - - - - - - 13 - 7 - 9 - - - - - - - - - - - - - 12 - 13 - - - - - - - CreateNewLocalObjectDef - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CreateNewLocalObjectDef - diff --git a/resources/boot/CA/ScriptFactory.xml b/resources/boot/CA/ScriptFactory.xml deleted file mode 100755 index dac5ba7..0000000 --- a/resources/boot/CA/ScriptFactory.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - 9 - - - - - - - - - - - 7 - 12 - - - - - - - - - - - 13 - 7 - 9 - - - - - - - - - - - - - 12 - 13 - - - - - - - CreateNewLocalObjectDef - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CreateNewLocalObjectDef - diff --git a/resources/boot/EA/AssignNewVersionFromLast.xml b/resources/boot/EA/AssignNewVersionFromLast.xml deleted file mode 100755 index 1ef30b5..0000000 --- a/resources/boot/EA/AssignNewVersionFromLast.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/EA/CreateNewLocalObjectDef.xml b/resources/boot/EA/CreateNewLocalObjectDef.xml deleted file mode 100755 index e4a9426..0000000 --- a/resources/boot/EA/CreateNewLocalObjectDef.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/EA/EditActivityDef.xml b/resources/boot/EA/EditActivityDef.xml deleted file mode 100755 index e90c225..0000000 --- a/resources/boot/EA/EditActivityDef.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/EA/EditProperties.xml b/resources/boot/EA/EditProperties.xml deleted file mode 100755 index 15d51b8..0000000 --- a/resources/boot/EA/EditProperties.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/EA/EditSchema.xml b/resources/boot/EA/EditSchema.xml deleted file mode 100755 index 3b01fdc..0000000 --- a/resources/boot/EA/EditSchema.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/EA/EditScriptDefinition.xml b/resources/boot/EA/EditScriptDefinition.xml deleted file mode 100755 index 11c14ec..0000000 --- a/resources/boot/EA/EditScriptDefinition.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/OD/CompositeActivityDef.xml b/resources/boot/OD/CompositeActivityDef.xml deleted file mode 100755 index e840734..0000000 --- a/resources/boot/OD/CompositeActivityDef.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/OD/CompositeActivityDef.xsd b/resources/boot/OD/CompositeActivityDef.xsd new file mode 100644 index 0000000..e840734 --- /dev/null +++ b/resources/boot/OD/CompositeActivityDef.xsd @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/boot/OD/CristalModule.xsd b/resources/boot/OD/CristalModule.xsd deleted file mode 100644 index 348ab8b..0000000 --- a/resources/boot/OD/CristalModule.xsd +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - Module Metadata - - - - - - - - - - - - - Configuration parameters to add to the Cristal VM on launch. May target either client or server processes. - - - - - - - - - - - - - - - - - - - - - - - Items to import into or verify within the Cristal server upon launch. - - - - - - - - - - - - - - - A composite activity outcome. - - - - - - - - - - - - Elementary activities - - - - - - - - - - - - Elementary activities - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Prefix for module components - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/OD/ElementaryActivityDef.xml b/resources/boot/OD/ElementaryActivityDef.xml deleted file mode 100755 index ea637e4..0000000 --- a/resources/boot/OD/ElementaryActivityDef.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/OD/ElementaryActivityDef.xsd b/resources/boot/OD/ElementaryActivityDef.xsd new file mode 100644 index 0000000..ea637e4 --- /dev/null +++ b/resources/boot/OD/ElementaryActivityDef.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/boot/OD/Module.xsd b/resources/boot/OD/Module.xsd new file mode 100644 index 0000000..78d34d7 --- /dev/null +++ b/resources/boot/OD/Module.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + Configuration parameters to add to the Cristal VM on launch. May target either client or server processes. + + + + + + + + + + + + + + + + + + + + + + + + Items to import into or verify within the Cristal server upon launch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prefix for module components + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/boot/OD/New.xml b/resources/boot/OD/New.xml deleted file mode 100755 index 91755c8..0000000 --- a/resources/boot/OD/New.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/resources/boot/OD/NewAgent.xml b/resources/boot/OD/NewAgent.xml deleted file mode 100755 index 773f4fc..0000000 --- a/resources/boot/OD/NewAgent.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - Complete Structure for new agent - - - - - - The initial roles that this Agent will hold - - - - - - - - diff --git a/resources/boot/OD/NewAgent.xsd b/resources/boot/OD/NewAgent.xsd new file mode 100644 index 0000000..773f4fc --- /dev/null +++ b/resources/boot/OD/NewAgent.xsd @@ -0,0 +1,20 @@ + + + + + + Complete Structure for new agent + + + + + + The initial roles that this Agent will hold + + + + + + + + diff --git a/resources/boot/OD/NewItem.xml b/resources/boot/OD/NewItem.xml deleted file mode 100755 index bcd5298..0000000 --- a/resources/boot/OD/NewItem.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - Complete Structure for new item - - - - - - New Properties for the item - - - - - - - - - A new collection with layout - - - - - - - - - The position and size of this member slot on the layout - - - - - - - - - - - - - - - - - - - - - - A new collection without layout - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/OD/NewItem.xsd b/resources/boot/OD/NewItem.xsd new file mode 100644 index 0000000..bcd5298 --- /dev/null +++ b/resources/boot/OD/NewItem.xsd @@ -0,0 +1,73 @@ + + + + + + Complete Structure for new item + + + + + + New Properties for the item + + + + + + + + + A new collection with layout + + + + + + + + + The position and size of this member slot on the layout + + + + + + + + + + + + + + + + + + + + + + A new collection without layout + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/boot/OD/NewLocalObjectDef.xml b/resources/boot/OD/NewLocalObjectDef.xml deleted file mode 100755 index 0186872..0000000 --- a/resources/boot/OD/NewLocalObjectDef.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - Please give a name for your new object. - - - - - If you want to store your object in a subfolder, give the subpath here. - - - - - - diff --git a/resources/boot/OD/PredefinedStepOutcome.xml b/resources/boot/OD/PredefinedStepOutcome.xml deleted file mode 100755 index bc0ac52..0000000 --- a/resources/boot/OD/PredefinedStepOutcome.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - General holder for predefined step outcomes we can't be bothered to define a proper schema for - - - - - - - - diff --git a/resources/boot/OD/PredefinedStepOutcome.xsd b/resources/boot/OD/PredefinedStepOutcome.xsd new file mode 100644 index 0000000..bc0ac52 --- /dev/null +++ b/resources/boot/OD/PredefinedStepOutcome.xsd @@ -0,0 +1,13 @@ + + + + + General holder for predefined step outcomes we can't be bothered to define a proper schema for + + + + + + + + diff --git a/resources/boot/OD/PropertyDescription.xml b/resources/boot/OD/PropertyDescription.xml deleted file mode 100755 index 886092a..0000000 --- a/resources/boot/OD/PropertyDescription.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - Defines the properties that will exist in instances of this description when initially created. - - - - - - - - The name of the new property. - - - - - Whether this property is used to identify the class of this item. Properties flagged as 'true' here are used to check type when these items are assigned to collections. - - - - - The initial value of the property when it is created. - - - - - Whether or not the property can have its value changed once it has been created. - - - - - - - - diff --git a/resources/boot/OD/PropertyDescription.xsd b/resources/boot/OD/PropertyDescription.xsd new file mode 100644 index 0000000..886092a --- /dev/null +++ b/resources/boot/OD/PropertyDescription.xsd @@ -0,0 +1,36 @@ + + + + + Defines the properties that will exist in instances of this description when initially created. + + + + + + + + The name of the new property. + + + + + Whether this property is used to identify the class of this item. Properties flagged as 'true' here are used to check type when these items are assigned to collections. + + + + + The initial value of the property when it is created. + + + + + Whether or not the property can have its value changed once it has been created. + + + + + + + + diff --git a/resources/boot/OD/Schema.xml b/resources/boot/OD/Schema.xml deleted file mode 100755 index fed1949..0000000 --- a/resources/boot/OD/Schema.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/resources/boot/OD/Schema.xsd b/resources/boot/OD/Schema.xsd new file mode 100644 index 0000000..fed1949 --- /dev/null +++ b/resources/boot/OD/Schema.xsd @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/boot/OD/Script.xml b/resources/boot/OD/Script.xml deleted file mode 100755 index 5726aca..0000000 --- a/resources/boot/OD/Script.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/boot/OD/Script.xsd b/resources/boot/OD/Script.xsd new file mode 100644 index 0000000..5726aca --- /dev/null +++ b/resources/boot/OD/Script.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/boot/SC/CreateNewNumberedVersionFromLast.xml b/resources/boot/SC/CreateNewNumberedVersionFromLast.xml deleted file mode 100755 index bb66f4c..0000000 --- a/resources/boot/SC/CreateNewNumberedVersionFromLast.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - diff --git a/resources/boot/SC/LocalObjectDefCreator.xml b/resources/boot/SC/LocalObjectDefCreator.xml deleted file mode 100755 index c57cbc1..0000000 --- a/resources/boot/SC/LocalObjectDefCreator.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - diff --git a/resources/boot/SC/New.xml b/resources/boot/SC/New.xml deleted file mode 100755 index a706310..0000000 --- a/resources/boot/SC/New.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/resources/boot/allbootitems.txt b/resources/boot/allbootitems.txt old mode 100755 new mode 100644 index 004bdf1..277699c --- a/resources/boot/allbootitems.txt +++ b/resources/boot/allbootitems.txt @@ -1,34 +1,14 @@ -OD/Schema OD/CompositeActivityDef OD/ElementaryActivityDef +OD/Module +OD/NewAgent +OD/NewItem OD/PredefinedStepOutcome OD/PropertyDescription +OD/Schema OD/Script -OD/NewLocalObjectDef -OD/NewItem -OD/NewAgent -EA/AssignNewVersionFromLast -EA/EditActivityDef -EA/EditSchema -EA/EditScriptDefinition -EA/CreateNewLocalObjectDef EA/CreateNewItem EA/CreateNewAgent -EA/EditProperties -CA/ManageCompositeActDef -CA/ManageElementaryActDef -CA/ManageSchema -CA/ManageScript -CA/SchemaFactory -CA/CompositeActivityFactory -CA/ElementaryActivityFactory -CA/ScriptFactory CA/NoWorkflow CA/ServerItemWorkflow -SC/CreateNewNumberedVersionFromLast -SC/LocalObjectDefCreator SC/ServerNewEntity -factory/CA -factory/EA -factory/OD -factory/SC \ No newline at end of file diff --git a/resources/boot/factory/CA.xml b/resources/boot/factory/CA.xml deleted file mode 100755 index 908647a..0000000 --- a/resources/boot/factory/CA.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/resources/boot/factory/EA.xml b/resources/boot/factory/EA.xml deleted file mode 100755 index 1185f10..0000000 --- a/resources/boot/factory/EA.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/resources/boot/factory/OD.xml b/resources/boot/factory/OD.xml deleted file mode 100755 index 275048b..0000000 --- a/resources/boot/factory/OD.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/resources/boot/factory/SC.xml b/resources/boot/factory/SC.xml deleted file mode 100755 index 7f3f97e..0000000 --- a/resources/boot/factory/SC.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/resources/images/typeicons/localobjectfactory_16.png b/resources/images/typeicons/localobjectfactory_16.png deleted file mode 100755 index 9979ee7..0000000 Binary files a/resources/images/typeicons/localobjectfactory_16.png and /dev/null differ diff --git a/resources/images/typeicons/localobjectfactory_32.png b/resources/images/typeicons/localobjectfactory_32.png deleted file mode 100755 index f43f44f..0000000 Binary files a/resources/images/typeicons/localobjectfactory_32.png and /dev/null differ diff --git a/resources/mapFiles/ModuleMap.xml b/resources/mapFiles/ModuleMap.xml new file mode 100644 index 0000000..4bc4db1 --- /dev/null +++ b/resources/mapFiles/ModuleMap.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/mapFiles/index b/resources/mapFiles/index index 58295a1..03de6f2 100644 --- a/resources/mapFiles/index +++ b/resources/mapFiles/index @@ -7,4 +7,4 @@ CollectionMap.xml JobListMap.xml ViewpointMap.xml TransferMap.xml -NewEntityMap.xml \ No newline at end of file +NewEntityMap.xml diff --git a/resources/textFiles/version.txt b/resources/textFiles/version.txt old mode 100755 new mode 100644 index 17e85ef..64c18b9 --- a/resources/textFiles/version.txt +++ b/resources/textFiles/version.txt @@ -1 +1 @@ -C2Kernel V2.2 Build 2 \ No newline at end of file +C2Kernel V2.3 Build 1 \ No newline at end of file diff --git a/source/com/c2kernel/collection/AggregationMember.java b/source/com/c2kernel/collection/AggregationMember.java index d383f02..e3b213e 100644 --- a/source/com/c2kernel/collection/AggregationMember.java +++ b/source/com/c2kernel/collection/AggregationMember.java @@ -136,7 +136,7 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb public Image getImage() { if (image == null) { - image = Resource.getImageResource("typeicons/"+getProperties().get("Type")+"_16.png").getImage(); + image = Resource.findImage("typeicons/"+getProperties().get("Type")+"_16.png").getImage(); } return image; } diff --git a/source/com/c2kernel/events/History.java b/source/com/c2kernel/events/History.java index a964a72..868eaea 100644 --- a/source/com/c2kernel/events/History.java +++ b/source/com/c2kernel/events/History.java @@ -68,14 +68,9 @@ public class History extends RemoteMap { synchronized (this) { int newEventID = getLastId()+1; newEvent.setID(newEventID); - if (put(newEvent.getName(), newEvent) != null) { - lastID = newEventID; - return newEvent; - } - else { - Logger.error("History.addEvent() - Event storage failed!"); - return null; - } + put(newEvent.getName(), newEvent); + lastID = newEventID; + return newEvent; } } diff --git a/source/com/c2kernel/graph/view/EditorToolBar.java b/source/com/c2kernel/graph/view/EditorToolBar.java index f84b084..61c7409 100644 --- a/source/com/c2kernel/graph/view/EditorToolBar.java +++ b/source/com/c2kernel/graph/view/EditorToolBar.java @@ -62,15 +62,15 @@ public class EditorToolBar extends Box implements Printable protected JComboBox mEdgeTypeBox = new JComboBox(); // Mode buttons protected ButtonGroup mModeButtonGroup = new ButtonGroup(); - protected JToggleButton mVertexModeButton = new JToggleButton(Resource.getImageResource("graph/newvertex.png")); - protected JToggleButton mSelectModeButton = new JToggleButton(Resource.getImageResource("graph/selection.gif")); - protected JToggleButton mEdgeModeButton = new JToggleButton(Resource.getImageResource("graph/edge.png")); + protected JToggleButton mVertexModeButton = new JToggleButton(Resource.findImage("graph/newvertex.png")); + protected JToggleButton mSelectModeButton = new JToggleButton(Resource.findImage("graph/selection.gif")); + protected JToggleButton mEdgeModeButton = new JToggleButton(Resource.findImage("graph/edge.png")); // Normal buttons protected JButton[] mOtherButtons = null; - protected JButton mStartButton = new JButton(Resource.getImageResource("graph/start.png")); - protected JButton mDeleteButton = new JButton(Resource.getImageResource("graph/delete.png")); - protected JButton mPrintButton = new JButton(Resource.getImageResource("graph/print.png")); - protected JButton mCopyButton = new JButton(Resource.getImageResource("graph/copy.png")); + protected JButton mStartButton = new JButton(Resource.findImage("graph/start.png")); + protected JButton mDeleteButton = new JButton(Resource.findImage("graph/delete.png")); + protected JButton mPrintButton = new JButton(Resource.findImage("graph/print.png")); + protected JButton mCopyButton = new JButton(Resource.findImage("graph/copy.png")); // Controllers protected StartVertexController mStartVertexController = new StartVertexController(); protected DeletionController mDeletionController = new DeletionController(); diff --git a/source/com/c2kernel/graph/view/GraphPanel.java b/source/com/c2kernel/graph/view/GraphPanel.java index 5edd070..012fe25 100644 --- a/source/com/c2kernel/graph/view/GraphPanel.java +++ b/source/com/c2kernel/graph/view/GraphPanel.java @@ -27,7 +27,7 @@ public class GraphPanel extends JPanel implements Observer { protected final Paint mSelectionPaint = Color.black; protected final Paint mStartPaint = Color.green; - protected final Image mResizePadImg = Resource.getImageResource("graph/resizepad.gif").getImage(); + protected final Image mResizePadImg = Resource.findImage("graph/resizepad.gif").getImage(); protected final BasicStroke mDashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 5.0f }, 0.0f); protected GraphModelManager mGraphModelManager = null; diff --git a/source/com/c2kernel/gui/Console.java b/source/com/c2kernel/gui/Console.java index a16e6f6..3427f82 100644 --- a/source/com/c2kernel/gui/Console.java +++ b/source/com/c2kernel/gui/Console.java @@ -130,7 +130,9 @@ public class Console extends JFrame { getContentPane().add(inputBox); try { - Properties utilProps = FileStringUtility.loadConfigFile( Resource.getDomainResourceURL("ScriptUtils.conf").toString()); + // TODO: merge module script utilities together and prepend with namespace + Properties utilProps = FileStringUtility.loadConfigFile( Resource.findTextResource("ScriptUtils.conf") ); + Box utilBox = Box.createHorizontalBox(); for (Object name2 : utilProps.keySet()) { String name = (String) name2; diff --git a/source/com/c2kernel/gui/DynamicTreeBuilder.java b/source/com/c2kernel/gui/DynamicTreeBuilder.java index a72c156..050a76a 100644 --- a/source/com/c2kernel/gui/DynamicTreeBuilder.java +++ b/source/com/c2kernel/gui/DynamicTreeBuilder.java @@ -25,15 +25,15 @@ import com.c2kernel.utils.Resource; public class DynamicTreeBuilder implements NodeSubscriber { private DefaultTreeModel treeModel; - private DefaultMutableTreeNode parent; + private final DefaultMutableTreeNode parent; public short state = IDLE; public static final short IDLE = 0; public static final short LOADING = 1; public static final short PARTIAL = 2; public static final short FINISHED = 3; - private DefaultMutableTreeNode loading; - private static ImageIcon loadIcon = Resource.getImageResource("loading.gif"); - private static ImageIcon pauseIcon = Resource.getImageResource("reload.gif"); + private final DefaultMutableTreeNode loading; + private static ImageIcon loadIcon = Resource.findImage("loading.gif"); + private static ImageIcon pauseIcon = Resource.findImage("reload.gif"); /** * The newly created DynamicTreeBuilder records its parent node - the one for which it will build child nodes for. diff --git a/source/com/c2kernel/gui/EntityDetails.java b/source/com/c2kernel/gui/EntityDetails.java index 7cb4f66..0a04536 100644 --- a/source/com/c2kernel/gui/EntityDetails.java +++ b/source/com/c2kernel/gui/EntityDetails.java @@ -134,7 +134,7 @@ public class EntityDetails extends JPanel implements ChangeListener, Runnable { c.anchor = GridBagConstraints.NORTH; c.ipadx = 5; c.ipady = 5; - current = new JLabel(Resource.getImageResource("typeicons/"+myEntity.getIconName()+"_32.png")); + current = new JLabel(Resource.findImage("typeicons/"+myEntity.getIconName()+"_32.png")); gridbag.setConstraints(current, c); titlePanel.add(current); // Place Name/ID Label diff --git a/source/com/c2kernel/gui/EntityFinder.java b/source/com/c2kernel/gui/EntityFinder.java index 18038c9..0d53545 100644 --- a/source/com/c2kernel/gui/EntityFinder.java +++ b/source/com/c2kernel/gui/EntityFinder.java @@ -43,8 +43,8 @@ public class EntityFinder extends Box implements Runnable { static { try { - mNextIcon =Resource.getImageResource("next.png"); - mFindIcon =Resource.getImageResource("find.png"); + mNextIcon =Resource.findImage("next.png"); + mFindIcon =Resource.findImage("find.png"); } catch (Exception e) { @@ -187,8 +187,8 @@ public class EntityFinder extends Box implements Runnable { } private class ListenerButtonListener implements ItemListener { - private DomainKeyListener listener; - private JToggleButton listenerButton; + private final DomainKeyListener listener; + private final JToggleButton listenerButton; public ListenerButtonListener(DomainKeyListener newListener, JToggleButton listenerButton) { this.listener = newListener; diff --git a/source/com/c2kernel/gui/LoginBox.java b/source/com/c2kernel/gui/LoginBox.java index 415469b..aee469f 100644 --- a/source/com/c2kernel/gui/LoginBox.java +++ b/source/com/c2kernel/gui/LoginBox.java @@ -47,8 +47,8 @@ import com.c2kernel.utils.Resource; */ public class LoginBox extends JFrame { - private int xMov; - private int yMov; + private final int xMov; + private final int yMov; public String errorMessage=new String(""); private int maxNumberLogon; public boolean action = false; @@ -72,7 +72,7 @@ public class LoginBox extends JFrame { javax.swing.ImageIcon imageHolder,MainFrame mainFrame) { String iconFile = Gateway.getProperty("AppIcon"); if (iconFile != null) - this.setIconImage(Resource.getImageResource(iconFile).getImage()); + this.setIconImage(Resource.findImage(iconFile).getImage()); this.errorLabel.setText(bottomMessage); if (errorMessage.compareTo("")!=0) this.errorLabel.setText(errorMessage); mainFrameFather=mainFrame; diff --git a/source/com/c2kernel/gui/Main.java b/source/com/c2kernel/gui/Main.java index 5a9209e..7cf54cb 100644 --- a/source/com/c2kernel/gui/Main.java +++ b/source/com/c2kernel/gui/Main.java @@ -1,6 +1,7 @@ package com.c2kernel.gui; +import com.c2kernel.process.Gateway; import com.c2kernel.process.StandardClient; import com.c2kernel.utils.Logger; @@ -16,7 +17,7 @@ public class Main extends StandardClient { try { - standardSetUp(args); + Gateway.init(readC2KArgs(args), false); Logger.initConsole("GUI"); MainFrame client = new MainFrame(); client.showLogin(); @@ -28,7 +29,7 @@ public class Main extends StandardClient try { - standardTearDown(); + Gateway.close(); } catch(Exception ex1) { diff --git a/source/com/c2kernel/gui/MainFrame.java b/source/com/c2kernel/gui/MainFrame.java index 2e39d0d..d09bc4c 100644 --- a/source/com/c2kernel/gui/MainFrame.java +++ b/source/com/c2kernel/gui/MainFrame.java @@ -108,7 +108,7 @@ public class MainFrame extends javax.swing.JFrame { pictureUrl = new URL(logoURL); imageHolder = new ImageIcon(pictureUrl); } catch (java.net.MalformedURLException m) { - imageHolder = Resource.getImageResource(logoURL); + imageHolder = Resource.findImage(logoURL); } LoginBox login = @@ -133,10 +133,10 @@ public class MainFrame extends javax.swing.JFrame { String iconFile = Gateway.getProperty("AppIcon"); if (iconFile != null) - this.setIconImage(Resource.getImageResource(iconFile).getImage()); + this.setIconImage(Resource.findImage(iconFile).getImage()); //preload loading image - Resource.getImageResource("loading.gif"); + Resource.findImage("loading.gif"); // close listener addWindowListener(new java.awt.event.WindowAdapter() { @Override diff --git a/source/com/c2kernel/gui/MenuBuilder.java b/source/com/c2kernel/gui/MenuBuilder.java index 6d1bfbc..8acfca7 100644 --- a/source/com/c2kernel/gui/MenuBuilder.java +++ b/source/com/c2kernel/gui/MenuBuilder.java @@ -25,6 +25,7 @@ import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.text.html.HTMLEditorKit; +import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.Path; import com.c2kernel.persistency.ClusterStorage; @@ -218,14 +219,23 @@ public class MenuBuilder extends JMenuBar implements ActionListener, ItemListene JLabel title = new JLabel(aboutInfo); about.add(title); - about.add(new JLabel("Domain version: "+Resource.getDomainVersion())); about.add(new JLabel("Kernel version: "+Resource.getKernelVersion())); + about.add(new JLabel("Modules loaded: "+Gateway.getModuleManager().getModuleVersions())); // get license info + StringBuffer lictxt = new StringBuffer(); - String domlictxt = Resource.getTextResource("license.html"); - if (domlictxt != null) - lictxt.append(domlictxt); - lictxt.append(Resource.getTextResource("textFiles/license.html")); + try { + lictxt.append(Resource.getTextResource(null, "textFiles/license.html")); + } catch (ObjectNotFoundException e) { } // no kernel license found + for (String ns : Resource.getModuleBaseURLs().keySet()) { + String domlictxt; + try { + domlictxt = Resource.getTextResource(ns, "license.html"); + lictxt.append(domlictxt).append("\n"); + } catch (ObjectNotFoundException e) { } + + } + JEditorPane license = new JEditorPane(); license.setEditable(false); @@ -242,7 +252,7 @@ public class MenuBuilder extends JMenuBar implements ActionListener, ItemListene myPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = myPane.createDialog(null, Language.translate("About")); dialog.setResizable(false); - Icon icon = Resource.getImageResource(Gateway.getProperty("banner")); + Icon icon = Resource.findImage(Gateway.getProperty("banner")); myPane.setIcon(icon); dialog.pack(); dialog.setVisible(true); diff --git a/source/com/c2kernel/gui/data/Node.java b/source/com/c2kernel/gui/data/Node.java index 6556b3a..2f12d6b 100644 --- a/source/com/c2kernel/gui/data/Node.java +++ b/source/com/c2kernel/gui/data/Node.java @@ -37,8 +37,8 @@ public abstract class Node implements Runnable { private boolean loaded = false; private String iconName; protected EntityTabManager desktop; - static ImageIcon folder = Resource.getImageResource("folder.png"); - static ImageIcon emptyLeaf = Resource.getImageResource("leaf.png"); + static ImageIcon folder = Resource.findImage("folder.png"); + static ImageIcon emptyLeaf = Resource.findImage("leaf.png"); public Node() { } @@ -214,7 +214,7 @@ public abstract class Node implements Runnable { public void setIcon(String icon) { iconName = icon; - this.icon = Resource.getImageResource("typeicons/"+icon+"_16.png"); + this.icon = Resource.findImage("typeicons/"+icon+"_16.png"); } public JPopupMenu getPopupMenu() { diff --git a/source/com/c2kernel/gui/tabs/EntityTabPane.java b/source/com/c2kernel/gui/tabs/EntityTabPane.java index 5a374dd..0a8a0cd 100644 --- a/source/com/c2kernel/gui/tabs/EntityTabPane.java +++ b/source/com/c2kernel/gui/tabs/EntityTabPane.java @@ -43,7 +43,7 @@ public class EntityTabPane extends JPanel implements Runnable { protected NodeEntity sourceEntity; protected String titleText = null; protected ImageIcon titleIcon = null; - private String tabName; + private final String tabName; protected GridBagLayout gridbag = new GridBagLayout(); protected GridBagConstraints c = null; public static Font titleFont = null; @@ -53,7 +53,7 @@ public class EntityTabPane extends JPanel implements Runnable { protected Box titleBox; static { try { - mReloadIcon = Resource.getImageResource("reload.gif"); + mReloadIcon = Resource.findImage("reload.gif"); } catch (Exception e) { Logger.warning("Couldn't load images: " + e); } @@ -96,7 +96,7 @@ public class EntityTabPane extends JPanel implements Runnable { if (titleText == null) titleText = tabName; if (titleIcon == null) - titleIcon = Resource.getImageResource("info.png"); + titleIcon = Resource.findImage("info.png"); JLabel title = new JLabel(titleText, titleIcon, SwingConstants.LEFT); title.setFont(titleFont); title.setForeground(headingColor); @@ -113,7 +113,7 @@ public class EntityTabPane extends JPanel implements Runnable { }); String defaultStartTab = MainFrame.getPref("DefaultStartTab", "Properties"); JToggleButton defaultStart = - new JToggleButton(Resource.getImageResource("graph/start.png")); + new JToggleButton(Resource.findImage("graph/start.png")); defaultStart.setMargin(new Insets(0, 0, 0, 0)); defaultStart.setToolTipText( Language.translate("Select this tab to be the default one opened when you double click an item")); diff --git a/source/com/c2kernel/gui/tabs/WorkflowPane.java b/source/com/c2kernel/gui/tabs/WorkflowPane.java index 6bccd08..e4acd8d 100644 --- a/source/com/c2kernel/gui/tabs/WorkflowPane.java +++ b/source/com/c2kernel/gui/tabs/WorkflowPane.java @@ -41,10 +41,10 @@ public class WorkflowPane extends EntityTabPane implements EntityProxyObserver { - protected JButton mSaveButton = new JButton(Resource.getImageResource("graph/save.png")); - protected JButton mHistoryButton = new JButton(Resource.getImageResource("graph/history.png")); + protected JButton mSaveButton = new JButton(Resource.findImage("graph/save.png")); + protected JButton mHistoryButton = new JButton(Resource.findImage("graph/history.png")); protected JButton[] mOtherToolBarButtons = { mSaveButton, mHistoryButton }; // Graph editor panel protected EditorPanel mEditorPanel; diff --git a/source/com/c2kernel/lifecycle/chooser/ActivityChooser.java b/source/com/c2kernel/lifecycle/chooser/ActivityChooser.java index 4b0ae4c..d5f62a0 100644 --- a/source/com/c2kernel/lifecycle/chooser/ActivityChooser.java +++ b/source/com/c2kernel/lifecycle/chooser/ActivityChooser.java @@ -56,7 +56,7 @@ public class ActivityChooser extends JFrame { super(title); mMessage = message; - img = Resource.getImageResource("graph/newvertex_large.png").getImage(); + img = Resource.findImage("graph/newvertex_large.png").getImage(); setIconImage(img); mParent = parent; mhashmap = hashmap; diff --git a/source/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java b/source/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java index da59efd..132fdcf 100644 --- a/source/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java +++ b/source/com/c2kernel/lifecycle/gui/model/WfVertexDefFactory.java @@ -38,7 +38,7 @@ public class WfVertexDefFactory implements VertexFactory, WorkflowDialogue new ActivityChooser( Language.translate("Please enter a Type for the new activityDef"), Language.translate("New " + vertexTypeId + " Activity"), - Resource.getImageResource("graph/newvertex_large.png").getImage(), + Resource.findImage("graph/newvertex_large.png").getImage(), this, mhm); a.setVisible(true); @@ -68,7 +68,7 @@ public class WfVertexDefFactory implements VertexFactory, WorkflowDialogue Language.translate("Please type a Name"), Language.translate("New " + vertexTypeId + " Activity"), JOptionPane.QUESTION_MESSAGE, - Resource.getImageResource("graph/newvertex_large.png"), + Resource.findImage("graph/newvertex_large.png"), null, null); act = (ActivityDef) mCompositeActivityDef.search(mCompositeActivityDef.getID() + "/" + newName); diff --git a/source/com/c2kernel/lifecycle/gui/view/CompActDefOutcomeHandler.java b/source/com/c2kernel/lifecycle/gui/view/CompActDefOutcomeHandler.java index 58964aa..4c69f15 100644 --- a/source/com/c2kernel/lifecycle/gui/view/CompActDefOutcomeHandler.java +++ b/source/com/c2kernel/lifecycle/gui/view/CompActDefOutcomeHandler.java @@ -45,8 +45,8 @@ public class CompActDefOutcomeHandler extends JPanel implements OutcomeHandler { - protected JButton mLoadButton = new JButton(Resource.getImageResource("graph/load.png")); - protected JButton mLayoutButton = new JButton(Resource.getImageResource("graph/autolayout.png")); + protected JButton mLoadButton = new JButton(Resource.findImage("graph/load.png")); + protected JButton mLayoutButton = new JButton(Resource.findImage("graph/autolayout.png")); protected JButton[] mOtherToolBarButtons = { mLayoutButton, mLoadButton }; protected CompositeActivityDef mCompActDef = null; diff --git a/source/com/c2kernel/lifecycle/instance/Activity.java b/source/com/c2kernel/lifecycle/instance/Activity.java index 226f0af..8a07d15 100644 --- a/source/com/c2kernel/lifecycle/instance/Activity.java +++ b/source/com/c2kernel/lifecycle/instance/Activity.java @@ -600,7 +600,7 @@ public class Activity extends WfVertex event = auditEvent(transitionID, agent); if (event != null) eventID = event.getID(); - if (Boolean.TRUE.equals(getProperties().get("AlwaysUseOutcome")) || transitionID == Transitions.DONE || transitionID == Transitions.COMPLETE) + if (transitionID == Transitions.DONE || transitionID == Transitions.COMPLETE) storeOutcome(eventID, requestData); EntityPath entityPath = getItemEntityPath(); TransactionManager storage = Gateway.getStorage(); diff --git a/source/com/c2kernel/lifecycle/instance/gui/model/WfVertexFactory.java b/source/com/c2kernel/lifecycle/instance/gui/model/WfVertexFactory.java index 0b6c9e4..39e7ee9 100644 --- a/source/com/c2kernel/lifecycle/instance/gui/model/WfVertexFactory.java +++ b/source/com/c2kernel/lifecycle/instance/gui/model/WfVertexFactory.java @@ -36,7 +36,7 @@ public class WfVertexFactory implements VertexFactory, WorkflowDialogue new ActivityChooser( Language.translate("Please enter a Type for the new activity"), Language.translate("New " + vertexTypeId + " Activity"), - Resource.getImageResource("graph/newvertex_large.png").getImage(), + Resource.findImage("graph/newvertex_large.png").getImage(), this, mhm); a.setVisible(true); @@ -69,7 +69,7 @@ public class WfVertexFactory implements VertexFactory, WorkflowDialogue Language.translate("Activity name not unique. Please give another."), Language.translate("New " + vertexTypeId + " Activity"), JOptionPane.QUESTION_MESSAGE, - Resource.getImageResource("graph/newvertex_large.png"), + Resource.findImage("graph/newvertex_large.png"), null, null); if (newName.equals("")) diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewAgent.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewAgent.java index 96371dd..aa30677 100644 --- a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewAgent.java +++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewAgent.java @@ -33,15 +33,17 @@ public class CreateNewAgent extends PredefinedStep InvalidDataException { checkAccessRights(agent); - + String redactedRequestData; try { NewAgent newAgent = (NewAgent)CastorXMLUtility.unmarshall(requestData); newAgent.create(agent.getSysKey()); + newAgent.password = "REDACTED"; + redactedRequestData = CastorXMLUtility.marshall(newAgent); } catch (Exception ex) { Logger.error(ex); throw new InvalidDataException("Error creating agent", ""); } - sendEventStoreOutcome(transitionID, requestData, agent); + sendEventStoreOutcome(transitionID, redactedRequestData, agent); } } diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java index 5666a00..f155ced 100644 --- a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java +++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java @@ -24,6 +24,7 @@ import com.c2kernel.utils.Logger; * * @version $Revision: 1.8 $ $Date: 2006/03/03 13:52:21 $ */ + public class NewItem { public String name; diff --git a/source/com/c2kernel/lookup/LDAPLookup.java b/source/com/c2kernel/lookup/LDAPLookup.java index 9bae873..39744ac 100644 --- a/source/com/c2kernel/lookup/LDAPLookup.java +++ b/source/com/c2kernel/lookup/LDAPLookup.java @@ -41,10 +41,10 @@ public class LDAPLookup { private LDAPConnection mLDAPConn; - private LDAPProperties mLDAPProps; - private NextKeyManager mNextKeyManager; + private final LDAPProperties mLDAPProps; + private final NextKeyManager mNextKeyManager; private LDAPPropertyManager mPropManager; - private LDAPRoleManager mRoleManager; + private final LDAPRoleManager mRoleManager; @@ -302,10 +302,10 @@ public class LDAPLookup LDAPLookupUtils.createCristalContext(getConnection(), Path.mLocalPath); } - public void install() + public void install() throws ObjectNotFoundException { createBootTree(); - initTree( Resource.getTextResource("boot/LDAPboot.txt")); + initTree( Resource.getTextResource(null, "boot/LDAPboot.txt")); } public void initTree(String bootFile) diff --git a/source/com/c2kernel/persistency/RemoteMap.java b/source/com/c2kernel/persistency/RemoteMap.java index bc17e3f..e57cae2 100644 --- a/source/com/c2kernel/persistency/RemoteMap.java +++ b/source/com/c2kernel/persistency/RemoteMap.java @@ -4,6 +4,7 @@ import java.util.AbstractSet; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; +import java.util.NoSuchElementException; import java.util.Set; import java.util.TreeMap; @@ -114,6 +115,7 @@ public class RemoteMap extends TreeMap impl public synchronized int getLastId() { loadKeys(); + if (size() == 0) return -1; try { return Integer.parseInt(lastKey()); } catch (NumberFormatException ex) { diff --git a/source/com/c2kernel/process/AbstractMain.java b/source/com/c2kernel/process/AbstractMain.java index 9282d45..7401d1b 100644 --- a/source/com/c2kernel/process/AbstractMain.java +++ b/source/com/c2kernel/process/AbstractMain.java @@ -16,7 +16,6 @@ import java.io.PrintStream; import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Logger; -import com.c2kernel.utils.Resource; /************************************************************************** * @@ -106,20 +105,6 @@ abstract public class AbstractMain } logStream = new PrintStream(new FileOutputStream(args[++i], true)); } - else if(args[i].equals("-resURL")) - { - String resString = args[++i]; - System.out.println("AbstractMain::readC2KArgs() - Resource location:" + - resString); - Resource.setKernelBaseURL(resString); - } - else if(args[i].equals("-domResURL")) - { - String resString = args[++i]; - System.out.println("AbstractMain::readC2KArgs() - Domain resource location:" + - resString); - Resource.setDomainBaseURL(resString); - } i++; } @@ -173,33 +158,4 @@ abstract public class AbstractMain return c2kProps; } - /************************************************************************** - * Required for most of the client & server application - * - * reads arguments - * initialises C2K properties - * initialises ORB - * initialises VirtualTreeManager - * initialises EventValueFactory + ProxyEventValueFactory - * initialises - **************************************************************************/ - static protected void standardSetUp(String[] args) - throws Exception - { - //Reads the C2Kernel arguments, and inits the Gateway with them - Gateway.init(readC2KArgs(args)); - - } - - - /************************************************************************** - * - **************************************************************************/ - static protected void standardTearDown() - throws Exception - { - Gateway.close(); - Logger.msg(5, "AbstractMain::standardTearDown() - DONE."); - } - } diff --git a/source/com/c2kernel/process/Bootstrap.java b/source/com/c2kernel/process/Bootstrap.java index 5011b7f..5b83d89 100644 --- a/source/com/c2kernel/process/Bootstrap.java +++ b/source/com/c2kernel/process/Bootstrap.java @@ -2,7 +2,6 @@ package com.c2kernel.process; import java.net.InetAddress; import java.util.Enumeration; -import java.util.HashMap; import java.util.StringTokenizer; import com.c2kernel.common.ObjectNotFoundException; @@ -15,7 +14,6 @@ import com.c2kernel.lifecycle.instance.CompositeActivity; import com.c2kernel.lifecycle.instance.Workflow; import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer; import com.c2kernel.lifecycle.instance.predefined.ServerPredefinedStepContainer; -import com.c2kernel.lifecycle.instance.predefined.entitycreation.NewItem; import com.c2kernel.lifecycle.instance.stateMachine.States; import com.c2kernel.lifecycle.instance.stateMachine.Transitions; import com.c2kernel.lookup.AgentPath; @@ -44,7 +42,6 @@ import com.c2kernel.utils.Resource; public class Bootstrap { - static HashMap bootstrapFactoryItems = new HashMap(); static DomainPath thisServerPath; /** @@ -68,8 +65,6 @@ public class Bootstrap // verify the server item's wf initServerItemWf(); - // create the factories etc. - createBootstrapFactoryItems(); Logger.msg("Bootstrap.run() - Bootstrapping complete"); } catch (Exception e) { Logger.error(e); @@ -86,45 +81,11 @@ public class Bootstrap String bootItems; Logger.msg(1, "Verifying kernel boot items"); bootItems = FileStringUtility.url2String(Resource.getKernelResourceURL("boot/allbootitems.txt")); - verifyBootDataItems(bootItems, true); - if (Resource.getDomainBaseURL() == null) - Logger.msg(1, "No Domain base URL. Skipping domain boot check."); - else { - try { - Logger.msg(1, "Verifying domain boot items"); - bootItems = FileStringUtility.url2String(Resource.getDomainResourceURL("boot/allbootitems.txt")); - verifyBootDataItems(bootItems, false); - } catch (Exception ex) { - Logger.error(ex); - Logger.msg("No domain boot items found."); - return; - } - Logger.msg(1, "Verifying domain agents"); - - try { - bootItems = FileStringUtility.url2String(Resource.getDomainResourceURL("boot/domainagents.txt")); - verifyDomainAgents(bootItems); - } catch (Exception ex) { - Logger.error(ex); - Logger.msg("No domain agents found."); - return; - } - } - + verifyBootDataItems(bootItems, null); Logger.msg(1, "Boot data items complete"); - - } - - private static void verifyDomainAgents(String agentFile) throws Exception { - StringTokenizer str = new StringTokenizer(agentFile, "\n\r"); - while (str.hasMoreTokens()) { - String thisItem = str.nextToken(); - StringTokenizer agent = new StringTokenizer(thisItem, ","); - checkAgent(agent.nextToken(), agent.nextToken(), agent.nextToken(), agent.nextToken().equalsIgnoreCase("true")); - } } - private static void verifyBootDataItems(String bootList, boolean isKernel) { + private static void verifyBootDataItems(String bootList, String ns) { StringTokenizer str = new StringTokenizer(bootList, "\n\r"); while (str.hasMoreTokens()) { String thisItem = str.nextToken(); @@ -132,63 +93,62 @@ public class Bootstrap String itemType = thisItem.substring(0,delim); String itemName = thisItem.substring(delim+1); try { - String data = Resource.getTextResource("boot/"+thisItem+".xml"); + String data = Resource.getTextResource(ns, "boot/"+thisItem+(itemType.equals("OD")?".xsd":".xml")); if (data == null) Logger.die("No data found for "+getDataType(itemType)+" "+itemName); - if (itemType.equals("factory")) { - bootstrapFactoryItems.put(itemName, data); - continue; - } - - Logger.msg(1, "Bootstrap.verifyBootItems() - Verifying data of "+getDataType(itemType)+" "+itemName); - Enumeration en = Gateway.getLDAPLookup().search(getTypeRoot(itemType), itemName); - ItemProxy thisProxy; - - if (!en.hasMoreElements()) { - Logger.msg("Bootstrap.verifyBootItems() - "+getDataType(itemType)+" "+itemName+" not found. Creating new."); - thisProxy = createBootstrapDataItem(itemType, itemName, isKernel); - } - else { - DomainPath path = (DomainPath)en.nextElement(); - thisProxy = (ItemProxy)Gateway.getProxyManager().getProxy(path); - try { - Viewpoint currentData = (Viewpoint)thisProxy.getObject(ClusterStorage.VIEWPOINT+"/"+getDataType(itemType)+"/last"); - String oldData = currentData.getOutcome().getData(); - if (data.equals(oldData)) { - Logger.msg(5, "Bootstrap.verifyBootItems() - Data identical, no update required"); - - continue; - } - } catch (ObjectNotFoundException ex) { - Logger.error("Bootstrap.verifyBootItems() - Item exists but no data found! Attempting to insert new."); - } - } - // data was missing or doesn't match - Logger.msg("Bootstrap.verifyBootItems() - Writing new data to "+getDataType(itemType)+" "+itemName); - History hist = (History)thisProxy.getObject(ClusterStorage.HISTORY); - Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Import", "Import", "Import", States.FINISHED); - Outcome newOutcome = new Outcome(newEvent.getID(), data, getDataType(itemType), 0); - Viewpoint newLastView = new Viewpoint(thisProxy.getSystemKey(), getDataType(itemType), "last", 0, newEvent.getID()); - Viewpoint newZeroView = new Viewpoint(thisProxy.getSystemKey(), getDataType(itemType), "0", 0, newEvent.getID()); - Gateway.getStorage().put(thisProxy.getSystemKey(), newOutcome, thisProxy); - Gateway.getStorage().put(thisProxy.getSystemKey(), newLastView, thisProxy); - Gateway.getStorage().put(thisProxy.getSystemKey(), newZeroView, thisProxy); - Gateway.getStorage().commit(thisProxy); + verifyResource(ns, itemName, itemType, data); } catch (Exception e) { Logger.error(e); Logger.die("Error importing bootstrap items. Unsafe to continue."); } } } + + + public static void verifyResource(String ns, String itemName, String itemType, String data) throws Exception { + Logger.msg(1, "Bootstrap.verifyResource() - Verifying data of "+getDataType(itemType)+" "+itemName); + Enumeration en = Gateway.getLDAPLookup().search(getTypeRoot(itemType), itemName); + ItemProxy thisProxy; + + if (!en.hasMoreElements()) { + Logger.msg("Bootstrap.verifyResource() - "+getDataType(itemType)+" "+itemName+" not found. Creating new."); + thisProxy = createResourceItem(itemType, itemName, ns); + } + else { + DomainPath path = (DomainPath)en.nextElement(); + thisProxy = (ItemProxy)Gateway.getProxyManager().getProxy(path); + try { + Viewpoint currentData = (Viewpoint)thisProxy.getObject(ClusterStorage.VIEWPOINT+"/"+getDataType(itemType)+"/last"); + String oldData = currentData.getOutcome().getData(); + if (data.equals(oldData)) { + Logger.msg(5, "Bootstrap.verifyResource() - Data identical, no update required"); + return; + } + } catch (ObjectNotFoundException ex) { + Logger.error("Bootstrap.verifyResource() - Item exists but no data found! Attempting to insert new."); + } + } + // data was missing or doesn't match + Logger.msg("Bootstrap.verifyResource() - Writing new data to "+getDataType(itemType)+" "+itemName); + History hist = (History)thisProxy.getObject(ClusterStorage.HISTORY); + Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Import", "Import", "Import", States.FINISHED); + Outcome newOutcome = new Outcome(newEvent.getID(), data, getDataType(itemType), 0); + Viewpoint newLastView = new Viewpoint(thisProxy.getSystemKey(), getDataType(itemType), "last", 0, newEvent.getID()); + Viewpoint newZeroView = new Viewpoint(thisProxy.getSystemKey(), getDataType(itemType), "0", 0, newEvent.getID()); + Gateway.getStorage().put(thisProxy.getSystemKey(), newOutcome, thisProxy); + Gateway.getStorage().put(thisProxy.getSystemKey(), newLastView, thisProxy); + Gateway.getStorage().put(thisProxy.getSystemKey(), newZeroView, thisProxy); + Gateway.getStorage().commit(thisProxy); + } /** * @param itemType * @param itemName * @param data */ - private static ItemProxy createBootstrapDataItem(String itemType, String itemName, boolean isKernel) throws Exception { + private static ItemProxy createResourceItem(String itemType, String itemName, String ns) throws Exception { // create props - PropertyDescriptionList pdList = (PropertyDescriptionList)CastorXMLUtility.unmarshall(Resource.getTextResource("boot/property/"+itemType+"Prop.xml")); + PropertyDescriptionList pdList = (PropertyDescriptionList)CastorXMLUtility.unmarshall(Resource.getTextResource(null, "boot/property/"+itemType+"Prop.xml")); PropertyArrayList props = new PropertyArrayList(); for (int i = 0; i < pdList.list.size(); i++) { PropertyDescription pd = pdList.list.get(i); @@ -204,7 +164,7 @@ public class Bootstrap 1, CastorXMLUtility.marshall(props), CastorXMLUtility.marshall(new CompositeActivity())); - DomainPath newDomPath = new DomainPath(getTypeRoot(itemType).toString()+"/system/"+(isKernel?"kernel":"domain")+"/"+itemName); + DomainPath newDomPath = new DomainPath(getTypeRoot(itemType).toString()+"/system/"+(ns==null?"kernel":ns)+"/"+itemName); newDomPath.setEntity(entityPath); Gateway.getLDAPLookup().add(newDomPath); return (ItemProxy)Gateway.getProxyManager().getProxy(entityPath); @@ -325,32 +285,4 @@ public class Bootstrap Gateway.getStorage().put(thisServerPath.getSysKey(), wf, null); // add this proxy server in case it was just registered, or the port has changed } - - public static void createBootstrapFactoryItems() throws Exception { - Logger.msg(1, "Verifying local object factories"); - for (String itemName : bootstrapFactoryItems.keySet()) { - String itemXML = bootstrapFactoryItems.get(itemName); - Logger.msg(2, "Verifying "+itemName); - NewItem item = (NewItem)CastorXMLUtility.unmarshall(itemXML); - DomainPath factPath = new DomainPath(new DomainPath(item.initialPath), item.name); - if (factPath.exists()) continue; - ItemProxy serverEntity = (ItemProxy)Gateway.getProxyManager().getProxy(thisServerPath); - serverEntity.requestAction( - Gateway.getLDAPLookup().getRoleManager().getAgentPath("system").getSysKey(), - "workflow/predefined/CreateNewItem", - Transitions.DONE, - itemXML); - Logger.msg("Bootstrap.createBootstrapFactoryItems() - Created factory item: "+itemName); - ItemProxy factProxy = (ItemProxy)Gateway.getProxyManager().getProxy(factPath); - String propDesc = Resource.getTextResource("boot/property/"+itemName+"Prop.xml"); - History hist = (History)factProxy.getObject(ClusterStorage.HISTORY); - Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Import", "Import", "Import", States.FINISHED); - Outcome newOutcome = new Outcome(newEvent.getID(), propDesc, "PropertyDescription", 0); - Viewpoint newLastView = new Viewpoint(factProxy.getSystemKey(), "PropertyDescription", "last", 0, newEvent.getID()); - Gateway.getStorage().put(factProxy.getSystemKey(), newOutcome, factProxy); - Gateway.getStorage().put(factProxy.getSystemKey(), newLastView, factProxy); - Gateway.getStorage().commit(factProxy); - } - } - } diff --git a/source/com/c2kernel/process/Gateway.java b/source/com/c2kernel/process/Gateway.java index 3a03088..f399351 100644 --- a/source/com/c2kernel/process/Gateway.java +++ b/source/com/c2kernel/process/Gateway.java @@ -5,8 +5,8 @@ package com.c2kernel.process; * @author $Author: abranson $ */ +import java.io.IOException; import java.net.MalformedURLException; -import java.net.URL; import java.util.Enumeration; import java.util.Properties; @@ -51,6 +51,7 @@ import com.c2kernel.utils.server.SimpleTCPIPServer; public class Gateway { static private Properties mC2KProps; + static private ModuleManager mModules; static private org.omg.CORBA.ORB mORB; static private LDAPLookup mLDAPLookup; static private TransactionManager mStorage; @@ -59,6 +60,7 @@ public class Gateway static private SimpleTCPIPServer mHTTPServer; + private Gateway() { } /** @@ -69,18 +71,21 @@ public class Gateway * If null, the java system properties are used * @throws InvalidDataException - invalid properties caused a failure in initialisation */ - static public void init(Properties props) throws InvalidDataException { + static public void init(Properties props, boolean isServer) throws InvalidDataException { + // if supplied props are null, use system props if (props == null) props = System.getProperties(); - // set resource URLs from config - String resURL = props.getProperty("KernelResourceURL"); - if (resURL != null && resURL.length()>0) - Resource.setKernelBaseURL(resURL); - - resURL = props.getProperty("DomainResourceURL"); - if (resURL != null && resURL.length()>0) - Resource.setDomainBaseURL(resURL); + // report version info + Logger.msg("Kernel version: "+Resource.getKernelVersion()); + + // init module manager + try { + mModules = new ModuleManager(ClassLoader.getSystemResources("module.xml"), isServer); + } catch (IOException e) { + Logger.error(e); + throw new InvalidDataException("Could not load module definitions. Classpath problem", ""); + } // Start with default props from kernel jar try { @@ -88,6 +93,13 @@ public class Gateway } catch (MalformedURLException ex) { Logger.die("Default properties not found. Probable cause is missing resources"); } + + // merge in module props + Properties moduleProperties = mModules.getAllModuleProperties(); + for (Enumeration e = moduleProperties.propertyNames(); e.hasMoreElements();) { + String propName = (String)e.nextElement(); + mC2KProps.put(propName, moduleProperties.get(propName)); + } // Overwrite with supplied props for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { @@ -98,15 +110,9 @@ public class Gateway // dump properties dumpC2KProps(7); - // report version info - Logger.msg("Domain version: "+Resource.getDomainVersion()); - Logger.msg("Kernel version: "+Resource.getKernelVersion()); - - // load kernel and domain mapfiles + // load kernel mapfiles try { CastorXMLUtility.loadMapsFrom(Resource.getKernelResourceURL("mapFiles/")); - if (Resource.getDomainBaseURL()!=null) - CastorXMLUtility.loadMapsFrom(Resource.getDomainResourceURL("mapFiles/")); } catch (MalformedURLException e1) { throw new InvalidDataException("Invalid Resource Location", ""); } @@ -117,12 +123,9 @@ public class Gateway Language.isTranlated=true; Language.mTableOfTranslation = FileStringUtility.loadLanguageFile(languageFile); } - - try { - Resource.setImportURL(new URL("file:"+getProperty("Import.dir"))); - } catch (MalformedURLException e) { - Logger.error("Import directory not set. "+getProperty("Import.dir")); - } + + // run module startup scripts + mModules.runScripts("startup"); } /** @@ -162,25 +165,32 @@ public class Gateway // start checking bootstrap items Bootstrap.run(); + // register modules + mModules.registerModules(); + } catch (Exception ex) { Logger.error(ex); Logger.die("Exception starting server components. Shutting down."); } // start the http server - try { - int httpPort = Integer.parseInt(Gateway.getProperty("ItemServer.HTTP.port")); - Logger.msg(2, "Starting HTTP Server on port "+httpPort); - mHTTPServer = new SimpleTCPIPServer(httpPort, ItemHTTPBridge.class, 5); - mHTTPServer.startListening(); - } catch (NumberFormatException ex) { - Logger.msg(3, "Invalid or no HTTP port defined. HTTP server not available."); - } +// try { +// int httpPort = Integer.parseInt(Gateway.getProperty("ItemServer.HTTP.port")); +// Logger.msg(2, "Starting HTTP Server on port "+httpPort); +// mHTTPServer = new SimpleTCPIPServer(httpPort, ItemHTTPBridge.class, 5); +// mHTTPServer.startListening(); +// } catch (NumberFormatException ex) { +// Logger.msg(3, "Invalid or no HTTP port defined. HTTP server not available."); +// } System.out.println("Server '"+Gateway.getCentreId()+"' initialised."); } - /** + public static ModuleManager getModuleManager() { + return mModules; + } + + /** * Connects to the LDAP server in an administrative context - using the admin username and * password given in the LDAP.user and LDAP.password props of the kernel properties. * @@ -327,6 +337,9 @@ public class Gateway */ public static void close() { + // run shutdown module scripts + mModules.runScripts("shutdown"); + // shut down servers if running if (mCorbaServer != null) mCorbaServer.close(); diff --git a/source/com/c2kernel/process/Module.java b/source/com/c2kernel/process/Module.java new file mode 100644 index 0000000..e32c72e --- /dev/null +++ b/source/com/c2kernel/process/Module.java @@ -0,0 +1,303 @@ +package com.c2kernel.process; + +import java.io.StringReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Properties; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; +import org.xml.sax.InputSource; + +import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.entity.proxy.ItemProxy; +import com.c2kernel.events.Event; +import com.c2kernel.events.History; +import com.c2kernel.lifecycle.instance.predefined.entitycreation.Dependency; +import com.c2kernel.lifecycle.instance.predefined.entitycreation.DependencyMember; +import com.c2kernel.lifecycle.instance.predefined.entitycreation.NewAgent; +import com.c2kernel.lifecycle.instance.predefined.entitycreation.NewItem; +import com.c2kernel.lifecycle.instance.predefined.entitycreation.Property; +import com.c2kernel.lifecycle.instance.stateMachine.States; +import com.c2kernel.lifecycle.instance.stateMachine.Transitions; +import com.c2kernel.lookup.DomainPath; +import com.c2kernel.persistency.ClusterStorage; +import com.c2kernel.persistency.outcome.Outcome; +import com.c2kernel.persistency.outcome.Viewpoint; +import com.c2kernel.scripting.ErrorInfo; +import com.c2kernel.scripting.Script; +import com.c2kernel.scripting.ScriptingEngineException; +import com.c2kernel.utils.CastorXMLUtility; +import com.c2kernel.utils.Logger; +import com.c2kernel.utils.Resource; + +public class Module { + + private final String ns, name, desc, version; + private String resURL; + private final ArrayList dependency = new ArrayList(); + private final Properties clientProps = new Properties(); + private final Properties serverProps = new Properties(); + private final HashMap clientScripts = new HashMap(); + private final HashMap serverScripts = new HashMap(); + private final ArrayList imports = new ArrayList(); + private static DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + private final DocumentBuilder parser; + + static { + dbf.setValidating(false); + dbf.setNamespaceAware(false); + } + + public Module(String moduleXML) throws Exception { + parser = dbf.newDocumentBuilder(); + Document moduleDOM = parser.parse(new InputSource(new StringReader(moduleXML))); + + Element root = (Element)moduleDOM.getElementsByTagName("CristalModule").item(0); + + // Get module metadata + ns = root.getAttribute("ns"); + name = root.getAttribute("name"); + Element info = (Element)moduleDOM.getElementsByTagName("Info").item(0); + desc = ((Text)info.getElementsByTagName("Description").item(0).getFirstChild()).getData(); + version = ((Text)info.getElementsByTagName("Version").item(0).getFirstChild()).getData(); + NodeList nl = info.getElementsByTagName("Dependency"); + for (int i=0; i0) { + resURL = ((Text)nl.item(0).getFirstChild()).getData(); + Resource.addModuleBaseURL(ns, resURL); + } + + // Get config properties + nl = root.getElementsByTagName("Config"); + for (int i=0; i0) { + Element impElem = (Element)nl.item(0); + nl = impElem.getChildNodes(); + for (int i=0; i scripts = isServer?serverScripts:clientScripts; + Script thisScript = scripts.get(event); + if (thisScript == null) return null; + try { + Object result = thisScript.execute(); + if (result instanceof ErrorInfo) + return (ErrorInfo)result; + else + return new ErrorInfo(result.toString()); + } catch (ScriptingEngineException ex) { + Logger.error(ex); + return new ErrorInfo("Error running "+event+" script in module "+ns); + } + } + + public void importAll(ItemProxy serverEntity) { + for (ModuleImport thisImp : imports) { + if (thisImp instanceof ModuleResource) { + ModuleResource thisRes = (ModuleResource)thisImp; + try { + Bootstrap.verifyResource(ns, thisRes.importName, thisRes.resourceType, Resource.getTextResource(ns, thisRes.resourceLocation)); + } catch (Exception ex) { + Logger.error(ex); + } + } + else if (thisImp instanceof ModuleItem) { + ModuleItem thisItem = (ModuleItem)thisImp; + try { + NewItem item = new NewItem(thisItem.importName, "/desc/"+ns, thisItem.workflow); + item.propertyList = thisItem.props; + DomainPath itemPath = new DomainPath(new DomainPath(item.initialPath), item.name); + if (itemPath.exists()) continue; + serverEntity.requestAction( + Gateway.getLDAPLookup().getRoleManager().getAgentPath("system").getSysKey(), + "workflow/predefined/CreateNewItem", + Transitions.DONE, + CastorXMLUtility.marshall(item)); + Logger.msg("Module.importAll() - Created item: "+thisItem.importName); + ItemProxy newProxy = (ItemProxy)Gateway.getProxyManager().getProxy(itemPath); + History hist = (History)newProxy.getObject(ClusterStorage.HISTORY); + for (String thisView : thisItem.outcomes.keySet()) { + String[] info = thisView.split(":"); + int version = Integer.parseInt(info[1]); + String data = Resource.getTextResource(ns, thisItem.outcomes.get(thisView)); + Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Import", "Import", "Import", States.FINISHED); + Outcome newOutcome = new Outcome(newEvent.getID(), data, info[0], version); + Viewpoint newLastView = new Viewpoint(newProxy.getSystemKey(), info[0], info[2], version, newEvent.getID()); + Gateway.getStorage().put(newProxy.getSystemKey(), newOutcome, newProxy); + Gateway.getStorage().put(newProxy.getSystemKey(), newLastView, newProxy); + } + for (Dependency thisDep : thisItem.deps) { + Gateway.getStorage().put(newProxy.getSystemKey(), thisDep.create(), newProxy); + } + Gateway.getStorage().commit(newProxy); + } catch (Exception ex) { + Logger.error("Error importing item "+thisItem.importName+" from module "+name); + Logger.error(ex); + } + } + else if (thisImp instanceof ModuleAgent) { + ModuleAgent thisAgent = (ModuleAgent)thisImp; + try { + Gateway.getLDAPLookup().getRoleManager().getAgentPath(thisAgent.importName); + Logger.msg(3, "Module.importAll() - User '"+thisAgent.importName+"' found."); + return; + } catch (ObjectNotFoundException ex) { } + Logger.msg("Module.importAll() - User '"+thisAgent.importName+"' not found. Creating."); + + NewAgent agent = new NewAgent(thisAgent.importName, thisAgent.password); + agent.roles = thisAgent.roles; + try { + serverEntity.requestAction( + Gateway.getLDAPLookup().getRoleManager().getAgentPath("system").getSysKey(), + "workflow/predefined/CreateNewAgent", + Transitions.DONE, + CastorXMLUtility.marshall(agent)); + } catch (Exception ex) { + Logger.error("Error importing agent "+thisAgent.importName+" from module "+name); + Logger.error(ex); + } + } + } + } + + public Properties getClientProperties() { + return clientProps; + } + + public Properties getServerProperties() { + return serverProps; + } + + public String getNs() { + return ns; + } + public String getName() { + return name; + } + public String getDesc() { + return desc; + } + public String getVersion() { + return version; + } + public String getResURL() { + return resURL; + } + public ArrayList getDependencies() { + return dependency; + } + public boolean hasDependency(String dep) { + return dependency.contains(dep); + } + + public abstract class ModuleImport { + String importName; + } + + public class ModuleResource extends ModuleImport { + String resourceType; + String resourceLocation; + } + + public class ModuleItem extends ModuleImport { + ArrayList props = new ArrayList(); + HashMap outcomes = new HashMap(); + ArrayList deps = new ArrayList(); + String workflow; + } + + public class ModuleAgent extends ModuleImport { + String password; + ArrayList roles = new ArrayList(); + } +} \ No newline at end of file diff --git a/source/com/c2kernel/process/ModuleManager.java b/source/com/c2kernel/process/ModuleManager.java new file mode 100644 index 0000000..e067a88 --- /dev/null +++ b/source/com/c2kernel/process/ModuleManager.java @@ -0,0 +1,81 @@ +package com.c2kernel.process; + +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Properties; + +import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.entity.proxy.ItemProxy; +import com.c2kernel.lookup.DomainPath; +import com.c2kernel.utils.FileStringUtility; +import com.c2kernel.utils.Logger; + +public class ModuleManager { + ArrayList modules = new ArrayList(); + Properties props = new Properties(); + boolean isServer; + + public ModuleManager(Enumeration moduleEnum, boolean isServer) { + this.isServer = isServer; + ArrayList loadedModules = new ArrayList(); + while(moduleEnum.hasMoreElements()) { + URL newModuleURL = moduleEnum.nextElement(); + try { + Module newModule = new Module(FileStringUtility.url2String(newModuleURL)); + modules.add(newModule); + loadedModules.add(newModule.getName()); + Properties modProp = isServer?newModule.getServerProperties():newModule.getClientProperties(); + for (Enumeration e = modProp.propertyNames(); e.hasMoreElements();) { + String propName = (String)e.nextElement(); + props.put(propName, modProp.get(propName)); + } + } catch (Exception e) { + Logger.error("Could not load module description from "+newModuleURL); + Logger.error(e); + } + } + + Logger.debug(5, "Checking dependencies"); + boolean depFailed = false; + for (Module thisMod : modules) { + ArrayList deps = thisMod.getDependencies(); + for (String dep : deps) { + if (!loadedModules.contains(dep)) { + Logger.error("UNMET MODULE DEPENDENCY: "+thisMod.getName()+" requires "+dep); + depFailed = true; + } + } + } + if (depFailed) Logger.die("Unmet module dependencies. Cannot continue"); + } + + public String getModuleVersions() { + StringBuffer ver = new StringBuffer(); + for (Module thisMod : modules) { + if (ver.length()>0) ver.append(";"); + ver.append(thisMod.getName()+"("+thisMod.getVersion()+")"); + } + return ver.toString(); + } + + + public Properties getAllModuleProperties() { + return props; + } + + public void runScripts(String event) { + for (Module thisMod : modules) { + thisMod.runScript(event, isServer); + } + } + + public void registerModules() throws ObjectNotFoundException { + ItemProxy serverEntity = (ItemProxy)Gateway.getProxyManager().getProxy(new DomainPath("/servers/"+Gateway.getProperty("ItemServer.name"))); + Logger.debug(3, "Registering modules"); + for (Module thisMod : modules) { + Logger.debug(4, "Registering module "+thisMod.getName()); + thisMod.importAll(serverEntity); + } + } +} diff --git a/source/com/c2kernel/process/StandardServer.java b/source/com/c2kernel/process/StandardServer.java index 72b761e..6804da5 100644 --- a/source/com/c2kernel/process/StandardServer.java +++ b/source/com/c2kernel/process/StandardServer.java @@ -43,7 +43,7 @@ public class StandardServer extends AbstractMain implements WrapperListener throws Exception { // read args and init Gateway - standardSetUp(args); + Gateway.init(readC2KArgs(args), true); // connect to LDAP as root Gateway.connect(); @@ -112,8 +112,7 @@ public class StandardServer extends AbstractMain implements WrapperListener public int stop(int arg0) { try { - // close gateway - standardTearDown(); + Gateway.close(); } catch( Exception ex ) { diff --git a/source/com/c2kernel/process/UserCodeProcess.java b/source/com/c2kernel/process/UserCodeProcess.java index 9c2deab..7779802 100644 --- a/source/com/c2kernel/process/UserCodeProcess.java +++ b/source/com/c2kernel/process/UserCodeProcess.java @@ -125,7 +125,7 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv // shut down try { - standardTearDown(); + Gateway.close(); } catch( Exception ex ) { @@ -196,7 +196,7 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv try { - standardSetUp(args); + Gateway.init(readC2KArgs(args), false); UserCodeProcess proc = getInstance(); new Thread(proc).start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @@ -212,7 +212,7 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv try { - standardTearDown(); + Gateway.close(); } catch(Exception ex1) { diff --git a/source/com/c2kernel/scripting/ErrorInfo.java b/source/com/c2kernel/scripting/ErrorInfo.java index f14038f..26c0384 100644 --- a/source/com/c2kernel/scripting/ErrorInfo.java +++ b/source/com/c2kernel/scripting/ErrorInfo.java @@ -18,6 +18,11 @@ public class ErrorInfo { super(); msg = new ArrayList(); } + + public ErrorInfo(String error) { + this(); + msg.add(error); + } public void addError(String error) { msg.add(error); diff --git a/source/com/c2kernel/scripting/Script.java b/source/com/c2kernel/scripting/Script.java index 0820c26..c056e95 100644 --- a/source/com/c2kernel/scripting/Script.java +++ b/source/com/c2kernel/scripting/Script.java @@ -72,19 +72,24 @@ public class Script * Creates a script executor for the supplied expression, bypassing the xml parsing bit * Output class is forced to an object. */ - public Script(String lang, String expr, BSFManager scriptManager) throws ScriptingEngineException + public Script(String lang, String expr, BSFManager scriptManager, Class returnType) throws ScriptingEngineException { setScriptEnv(scriptManager); mName = ""; mLang = lang; mVersion = ""; - mOutputClass = Object.class; + mOutputClass = returnType; mScript = expr; } public Script(String lang, String expr) throws ScriptingEngineException { - this(lang, expr, new BSFManager()); + this(lang, expr, new BSFManager(), Object.class); + } + + public Script(String lang, String expr, Class returnType) throws ScriptingEngineException + { + this(lang, expr, new BSFManager(), returnType); } public Script(ItemProxy object, AgentProxy subject, Job job) throws ScriptingEngineException diff --git a/source/com/c2kernel/scripting/ScriptConsole.java b/source/com/c2kernel/scripting/ScriptConsole.java index 33d4b7f..99ad90f 100644 --- a/source/com/c2kernel/scripting/ScriptConsole.java +++ b/source/com/c2kernel/scripting/ScriptConsole.java @@ -194,13 +194,13 @@ public class ScriptConsole implements SocketHandler { } catch (NumberFormatException ex) { } } else if(command.equals("help")) { - output.println(Resource.getTextResource("textFiles/consoleHelp.txt")); + output.println(Resource.findTextResource("textFiles/consoleHelp.txt")); continue; } else if(command.equals("version")) { - output.println("Domain version: "+Resource.getDomainVersion()); output.println("Kernel version: "+Resource.getKernelVersion()); - continue; + output.println("Modules loaded: "+Gateway.getModuleManager().getModuleVersions()); + continue; } try { if (command.endsWith("\\")) { diff --git a/source/com/c2kernel/utils/CastorArrayList.java b/source/com/c2kernel/utils/CastorArrayList.java index ed15c0f..ea9a090 100644 --- a/source/com/c2kernel/utils/CastorArrayList.java +++ b/source/com/c2kernel/utils/CastorArrayList.java @@ -15,7 +15,7 @@ import java.util.ArrayList; * All rights reserved. **************************************************************************/ // -abstract public class CastorArrayList implements Serializable{ +abstract public class CastorArrayList implements Serializable { public ArrayList list; public CastorArrayList() { diff --git a/source/com/c2kernel/utils/Resource.java b/source/com/c2kernel/utils/Resource.java index ba2f71a..10228da 100644 --- a/source/com/c2kernel/utils/Resource.java +++ b/source/com/c2kernel/utils/Resource.java @@ -3,7 +3,7 @@ package com.c2kernel.utils; //Java import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; +import java.util.HashMap; import java.util.Hashtable; import javax.swing.ImageIcon; @@ -19,42 +19,36 @@ public class Resource { static private Hashtable txtCache = new Hashtable(); static private Hashtable imgCache = new Hashtable(); static private URL baseURL = getURLorResURL("com/c2kernel/utils/resources/"); - static private ArrayList domainBaseURL = new ArrayList(); - static public ImageIcon nullImg = new ImageIcon(new byte[] { 0 }); - - /* - * Kernel Resource URL section - */ - public static void setKernelBaseURL(String newBaseURL) { - baseURL = getURLorResURL(newBaseURL); - } + static private HashMap moduleBaseURLs = new HashMap(); + static public final ImageIcon nullImg = new ImageIcon(new byte[] { 0 }); public static URL getKernelBaseURL() { return baseURL; } - static public URL getKernelResourceURL(String resName) throws MalformedURLException { + public static URL getKernelResourceURL(String resName) throws MalformedURLException { return new URL(baseURL, resName); } - - /* - * Domain Resource URL section - */ - public static void addDomainBaseURL(URL newBaseURL) { - domainBaseURL.add(newBaseURL); + public static void addModuleBaseURL(String ns, URL newBaseURL) { + moduleBaseURLs.put(ns, newBaseURL); + Logger.msg("Adding resource URL for "+ns+": "+newBaseURL.toString()); } - public static void addDomainBaseURL(String newBaseURL) { - addDomainBaseURL(getURLorResURL(newBaseURL)); + public static void addModuleBaseURL(String ns, String newBaseURL) { + addModuleBaseURL(ns, getURLorResURL(newBaseURL)); } - public static ArrayList getDomainBaseURL() { - return domainBaseURL; + public static URL getModuleBaseURL(String ns) { + return moduleBaseURLs.get(ns); + } + + public static HashMap getModuleBaseURLs() { + return moduleBaseURLs; } - static public URL getDomainResourceURL(String resName) throws MalformedURLException { - return new URL(domainBaseURL, resName); + static public URL getModuleResourceURL(String ns, String resName) throws MalformedURLException { + return new URL(moduleBaseURLs.get(ns), resName); } private static URL getURLorResURL(String newURL) { @@ -71,29 +65,44 @@ public class Resource { /************************************************************************** * Gets any text resource files **************************************************************************/ - static public String getTextResource(String resName) + + static public String findTextResource(String resName) { + try { + for (String ns : getModuleBaseURLs().keySet()) { + try { + return getTextResource(ns, resName); + } catch (ObjectNotFoundException ex) { } + } + return getTextResource(null, resName); + } catch (ObjectNotFoundException ex) { + Logger.warning("Text resource '"+resName+"' not found."); + return null; + } + } + + static public String getTextResource(String ns, String resName) throws ObjectNotFoundException // throws IOException { Logger.msg(8, "Resource::getTextResource() - Getting resource: " + resName); - if (txtCache.containsKey(resName)) { - return txtCache.get(resName); + if (txtCache.containsKey(ns+'/'+resName)) { + return txtCache.get(ns+'/'+resName); } try { String newRes = null; - try { - newRes = FileStringUtility.url2String(getDomainResourceURL(resName)); - } catch (Exception ex) { } // no domain base - - if (newRes == null || newRes.length() == 0) { // not found in domain - newRes = FileStringUtility.url2String(getKernelResourceURL(resName)); - } - txtCache.put(resName, newRes); + URL loc; + + if (ns == null) // kernel + loc = getKernelResourceURL(resName); + else + loc = getModuleResourceURL(ns, resName); + newRes = FileStringUtility.url2String(loc); + txtCache.put(ns+'/'+resName, newRes); return newRes; } catch (Exception e) { - return null; + throw new ObjectNotFoundException(e.getMessage(),null); } } /** @@ -102,57 +111,48 @@ public class Resource { * @param resName - filename after resources/images * @return */ - static public ImageIcon getImageResource(String resName) { + static public ImageIcon findImage(String resName) { try { - return getImage(resName); + for (String ns : getModuleBaseURLs().keySet()) { + try { + return getImage(ns, resName); + } catch (ObjectNotFoundException ex) { } + } + return getImage(null, resName); } catch (ObjectNotFoundException ex) { - Logger.error("Image "+resName+" not found. Using null icon"); + Logger.warning("Image '"+resName+"' not found. Using null icon"); return nullImg; } } - static public ImageIcon getImage(String resName) throws ObjectNotFoundException { + static public ImageIcon getImage(String ns, String resName) throws ObjectNotFoundException { if (resName == null) return nullImg; - if (imgCache.containsKey(resName)) { - return imgCache.get(resName); + if (imgCache.containsKey(ns+'/'+resName)) { + return imgCache.get(ns+'/'+resName); } URL imgLocation = null; - ImageIcon newImg = null; - // try domain resources first - if (domainBaseURL != null) { - try { - imgLocation = new URL(domainBaseURL + "images/" + resName.toLowerCase()); - newImg = new ImageIcon(imgLocation); - } catch (MalformedURLException e) { } - } - - // try kernel resources next - if (newImg == null || newImg.getIconHeight() == -1) { - try { - imgLocation = new URL(baseURL + "images/" + resName.toLowerCase()); - newImg = new ImageIcon(imgLocation); - } catch (MalformedURLException e) { } - } - - // else return null image - if (newImg == null || newImg.getIconHeight() == -1) { - throw new ObjectNotFoundException(); - } - - else imgCache.put(resName, newImg); - Logger.msg(7, "Loaded "+resName+" "+newImg.getIconWidth()+"x"+newImg.getIconHeight()); - return newImg; - } - - static public String getDomainVersion() { - try { - return FileStringUtility.url2String(getDomainResourceURL("version.txt")); - } catch (Exception ex) { - return "Domain application version not found"; - } + if (ns == null) + try { + imgLocation = getKernelResourceURL("images/"+resName); + } catch (MalformedURLException ex) { } + else + try { + imgLocation = getModuleResourceURL(ns, "images/"+resName); + } catch (MalformedURLException ex) { } + + if (imgLocation!= null) { + ImageIcon newImg = new ImageIcon(imgLocation); + + if (newImg.getIconHeight() > -1) { + imgCache.put(ns+'/'+resName, newImg); + Logger.msg(0, "Loaded "+resName+" "+newImg.getIconWidth()+"x"+newImg.getIconHeight()); + return newImg; + } + } + throw new ObjectNotFoundException(); } static public String getKernelVersion() { -- cgit v1.2.3