summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-08-16 09:01:59 (EDT)
committer Manik Kishore2012-08-16 09:01:59 (EDT)
commitb105a631114d0b16d65bff3071387af6884bafc7 (patch)
treef77cfcccb683b537eb9bcea563f8dcd2821c1f77
parent51f8e395636ec6e27dd72cef9826abb58eabe8e1 (diff)
downloadorg.eclipse.stardust.ide-b105a631114d0b16d65bff3071387af6884bafc7.zip
org.eclipse.stardust.ide-b105a631114d0b16d65bff3071387af6884bafc7.tar.gz
org.eclipse.stardust.ide-b105a631114d0b16d65bff3071387af6884bafc7.tar.bz2
CRNT-25760 Refactor/Clean up MB Facade: Remove Singleton stuff
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide@58461 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java16
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrConnectionManager.java11
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrModelManager.java11
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java26
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/XpdlModelIoUtils.java17
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java32
6 files changed, 60 insertions, 53 deletions
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java
index 1b5e617..1767b75 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/connectionhandler/JcrConnectionHandler.java
@@ -27,13 +27,11 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
-
import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.engine.api.runtime.Document;
import org.eclipse.stardust.engine.api.runtime.DocumentManagementService;
import org.eclipse.stardust.model.xpdl.builder.strategy.ModelManagementStrategy;
import org.eclipse.stardust.model.xpdl.builder.utils.JcrConnectionManager;
-import org.eclipse.stardust.model.xpdl.builder.utils.MBFacade;
import org.eclipse.stardust.model.xpdl.builder.utils.PepperIconFactory;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
import org.eclipse.stardust.model.xpdl.carnot.util.CarnotConstants;
@@ -51,8 +49,9 @@ import org.eclipse.stardust.modeling.repository.common.descriptors.EObjectDescri
import org.eclipse.stardust.modeling.repository.common.descriptors.ModelElementDescriptor;
import org.eclipse.stardust.modeling.repository.common.util.ImportUtils;
+
public class JcrConnectionHandler implements ConnectionHandler
-{
+{
DocumentManagementService documentManagementService;
private static final String MODELS_DIR = "/process-models/";
@@ -62,6 +61,7 @@ public class JcrConnectionHandler implements ConnectionHandler
private URI uri;
private IObjectDescriptor[] children = null;
private Connection connection;
+ private ModelManagementStrategy strategy;
private static final List<String> PARTICIPANTS = Arrays.asList(new String[] {
"role", "organization", "conditionalPerformer"
@@ -72,11 +72,15 @@ public class JcrConnectionHandler implements ConnectionHandler
private EObjectDescriptor modelDescriptor;
private ModelType model;
+ public JcrConnectionHandler(ModelManagementStrategy strategy)
+ {
+ this.strategy = strategy;
+ }
+
synchronized ModelType loadModel(String id)
{
- // TODO properly resolve current modelManagementStrategy
- ModelManagementStrategy modelManagementStrategy = MBFacade.getInstance().getModelManagementStrategy();
- return modelManagementStrategy.loadModel(id);
+
+ return strategy.loadModel(id);
}
private byte[] readModelContext(Document modelDocument) {
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrConnectionManager.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrConnectionManager.java
index a83ee7b..26134b8 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrConnectionManager.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrConnectionManager.java
@@ -33,6 +33,7 @@ import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.engine.api.model.PredefinedConstants;
import org.eclipse.stardust.model.xpdl.builder.connectionhandler.JcrConnectionHandler;
+import org.eclipse.stardust.model.xpdl.builder.strategy.ModelManagementStrategy;
import org.eclipse.stardust.model.xpdl.carnot.ApplicationType;
import org.eclipse.stardust.model.xpdl.carnot.AttributeType;
import org.eclipse.stardust.model.xpdl.carnot.ConditionalPerformerType;
@@ -67,6 +68,8 @@ import org.eclipse.stardust.modeling.repository.common.descriptors.EObjectDescri
public class JcrConnectionManager implements IConnectionManager
{
+ private static ModelManagementStrategy strategy;
+
private static final IFilter BY_REF_FILTER = new IFilter()
{
public boolean accept(Object object)
@@ -160,6 +163,7 @@ public class JcrConnectionManager implements IConnectionManager
private ModelType model;
+
// attribute name
public void setModel(ModelType model)
@@ -168,8 +172,9 @@ public class JcrConnectionManager implements IConnectionManager
model.setConnectionManager(this);
}
- public JcrConnectionManager(ModelType model)
+ public JcrConnectionManager(ModelType model, ModelManagementStrategy strategy)
{
+ this.strategy = strategy;
this.model = model;
this.model.setConnectionManager(this);
@@ -429,7 +434,7 @@ public class JcrConnectionManager implements IConnectionManager
private ConnectionHandler createHandler(String type) throws CoreException
{
- return new JcrConnectionHandler();
+ return new JcrConnectionHandler(strategy);
}
public void close(Connection connection) throws CoreException
@@ -870,7 +875,7 @@ public class JcrConnectionManager implements IConnectionManager
{
String id = null;
- JcrConnectionManager jcrConnectionManager = XpdlModelIoUtils.getJcrConnectionManager(model);
+ JcrConnectionManager jcrConnectionManager = XpdlModelIoUtils.getJcrConnectionManager(model, strategy);
IConnection findConnection = jcrConnectionManager.getConnectionForAttribute("project:/" + referencedModel.getName() + ".xpdl");
if(findConnection == null)
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrModelManager.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrModelManager.java
index 42516b2..a4d9e1b 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrModelManager.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/JcrModelManager.java
@@ -21,6 +21,7 @@ import org.eclipse.stardust.common.StringUtils;
import org.eclipse.stardust.common.config.Parameters;
import org.eclipse.stardust.common.utils.xml.XmlProperties;
import org.eclipse.stardust.engine.core.model.xpdl.XpdlUtils;
+import org.eclipse.stardust.model.xpdl.builder.strategy.ModelManagementStrategy;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
import org.eclipse.stardust.model.xpdl.carnot.util.WorkflowModelManager;
@@ -28,12 +29,18 @@ public class JcrModelManager extends WorkflowModelManager
{
private JcrConnectionManager manager;
private ModelType saveModel;
+ private ModelManagementStrategy strategy;
public JcrModelManager()
{
super();
}
+ public JcrModelManager(ModelManagementStrategy strategy)
+ {
+ this.strategy = strategy;
+ }
+
public void setModel(ModelType model)
{
saveModel = model;
@@ -44,7 +51,7 @@ public class JcrModelManager extends WorkflowModelManager
{
if (model != null && model.getId() != null)
{
- manager = XpdlModelIoUtils.getJcrConnectionManager(model);
+ manager = XpdlModelIoUtils.getJcrConnectionManager(model, strategy);
manager.resolve();
}
super.resolve(model);
@@ -54,7 +61,7 @@ public class JcrModelManager extends WorkflowModelManager
{
if (manager == null)
{
- manager = XpdlModelIoUtils.getJcrConnectionManager(saveModel);
+ manager = XpdlModelIoUtils.getJcrConnectionManager(saveModel, strategy);
if(saveModel.getConnectionManager() == null)
{
saveModel.setConnectionManager(manager);
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java
index 354508f..5d309fa 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/MBFacade.java
@@ -31,7 +31,6 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.stardust.common.StringUtils;
import org.eclipse.stardust.common.error.ObjectNotFoundException;
-import org.eclipse.stardust.engine.api.runtime.DeploymentException;
import org.eclipse.stardust.engine.core.pojo.data.Type;
import org.eclipse.stardust.engine.core.struct.StructuredDataConstants;
import org.eclipse.stardust.model.xpdl.builder.activity.BpmApplicationActivityBuilder;
@@ -82,29 +81,18 @@ import org.eclipse.xsd.XSDSchema;
public class MBFacade
{
- private final static MBFacade mbFacade;
+
private ModelManagementStrategy modelManagementStrategy;
- static
- {
- mbFacade = new MBFacade();
- }
-
- private MBFacade()
- {
-
- }
-
- public static MBFacade getInstance()
+ public MBFacade(ModelManagementStrategy modelManagementStrategy)
{
- return mbFacade;
+ this.modelManagementStrategy = modelManagementStrategy;
}
- public static MBFacade getInstance(ModelManagementStrategy modelManagementStrategy)
+ public MBFacade()
{
- mbFacade.modelManagementStrategy = modelManagementStrategy;
- return mbFacade;
+ // TODO Auto-generated constructor stub
}
public ModelManagementStrategy getModelManagementStrategy()
@@ -147,7 +135,7 @@ public class MBFacade
* @param participant
* @return list of organizations
*/
- public List<OrganizationType> getParentOrganizations(ModelType model,
+ public static List<OrganizationType> getParentOrganizations(ModelType model,
IModelParticipant participant)
{
List<OrganizationType> belongsTo = new ArrayList<OrganizationType>();
@@ -268,7 +256,7 @@ public class MBFacade
String typeFullID)
{
DataType data;
- String sourceModelID = MBFacade.getInstance().getModelId(typeFullID);
+ String sourceModelID = getModelId(typeFullID);
ModelType typeDeclarationModel = getModelManagementStrategy().getModels().get(
sourceModelID);
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/XpdlModelIoUtils.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/XpdlModelIoUtils.java
index 2af7819..9901f84 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/XpdlModelIoUtils.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/utils/XpdlModelIoUtils.java
@@ -34,6 +34,7 @@ import org.eclipse.stardust.common.log.LogManager;
import org.eclipse.stardust.common.log.Logger;
import org.eclipse.stardust.common.utils.xml.XmlProperties;
import org.eclipse.stardust.engine.core.model.xpdl.XpdlUtils;
+import org.eclipse.stardust.model.xpdl.builder.strategy.ModelManagementStrategy;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
import org.eclipse.stardust.model.xpdl.carnot.impl.DocumentRootImpl;
import org.eclipse.stardust.model.xpdl.carnot.util.WorkflowModelManager;
@@ -63,7 +64,7 @@ public class XpdlModelIoUtils
return modelMap.get(id);
}
- public static JcrConnectionManager getJcrConnectionManager(ModelType model)
+ public static JcrConnectionManager getJcrConnectionManager(ModelType model, ModelManagementStrategy strategy)
{
if(modelMap.get(model.getId()) == null)
{
@@ -73,21 +74,21 @@ public class XpdlModelIoUtils
JcrConnectionManager manager = map.get(model.getId());
if(manager == null)
{
- manager = new JcrConnectionManager(model);
+ manager = new JcrConnectionManager(model, strategy);
map.put(model.getId(), manager);
}
return manager;
}
- public static ModelType loadModel(byte[] modelXml)
+ public static ModelType loadModel(byte[] modelXml, ModelManagementStrategy strategy)
{
try
{
ByteArrayInputStream modelXmlReader = new ByteArrayInputStream(modelXml);
try
{
- return loadModel(modelXmlReader);
+ return loadModel(modelXmlReader, strategy);
}
finally
{
@@ -102,14 +103,14 @@ public class XpdlModelIoUtils
}
}
- public static ModelType loadModel(InputStream modelXml) throws IOException
+ public static ModelType loadModel(InputStream modelXml, ModelManagementStrategy strategy) throws IOException
{
File tmpPackage = null;
try
{
tmpPackage = copyToTmpXpdlFile(modelXml);
- return loadModel(tmpPackage);
+ return loadModel(tmpPackage, strategy);
}
finally
{
@@ -120,7 +121,7 @@ public class XpdlModelIoUtils
}
}
- public static ModelType loadModel(File modelXml) throws IOException
+ public static ModelType loadModel(File modelXml, ModelManagementStrategy strategy) throws IOException
{
// optionally override default TraxFactory to get rid of a Xalan related bug of loosing namespace alias declarations
final String ippTraxFactory = Parameters.instance().getString(
@@ -134,7 +135,7 @@ public class XpdlModelIoUtils
System.setProperty(TransformerFactory.class.getName(), ippTraxFactory);
}
- WorkflowModelManager modelMgr = new JcrModelManager();
+ WorkflowModelManager modelMgr = new JcrModelManager(strategy);
try
{
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java b/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java
index 2d5a4dc..6cc9c6b 100644
--- a/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/test/java/org/eclipse/stardust/model/xpdl/builder/CrossModelSupportModelBuilderTest.java
@@ -37,7 +37,9 @@ public class CrossModelSupportModelBuilderTest
@Before
public void initCrossModeling()
{
- strategy = new InMemoryModelManagementStrategy();
+ strategy = new InMemoryModelManagementStrategy();
+
+ MBFacade facade = new MBFacade(strategy);
ModelType providerModel = newBpmModel().withName("ProviderModel").build();
ModelType consumerModel = newBpmModel().withName("ConsumerModel").build();
@@ -45,33 +47,33 @@ public class CrossModelSupportModelBuilderTest
strategy.loadModels().add(providerModel);
//Participants
- MBFacade.getInstance(strategy).createRole(providerModel, "Administrator", "Administrator");
- MBFacade.getInstance().createRole(consumerModel, "Administrator", "Administrator");
+ facade.createRole(providerModel, "Administrator", "Administrator");
+ facade.createRole(consumerModel, "Administrator", "Administrator");
//Primitive Data
- MBFacade.getInstance().createPrimitiveData(providerModel, "ProvidedPrimitive", "ProvidedPrimitive", ModelerConstants.STRING_PRIMITIVE_DATA_TYPE);
+ facade.createPrimitiveData(providerModel, "ProvidedPrimitive", "ProvidedPrimitive", ModelerConstants.STRING_PRIMITIVE_DATA_TYPE);
//Type Declaration
- MBFacade.getInstance().createTypeDeclaration(providerModel, "ProvidedComposite", "ProvidedComposite");
+ facade.createTypeDeclaration(providerModel, "ProvidedComposite", "ProvidedComposite");
//Processes
- ProcessDefinitionType providedProcess = MBFacade.getInstance().createProcess(providerModel, "ProvidedProcess", "ProvidedProcess");
- ProcessDefinitionType providedProcess2 = MBFacade.getInstance().createProcess(providerModel, "ProvidedProcess2", "ProvidedProcess2");
- ProcessDefinitionType consumerProcess = MBFacade.getInstance().createProcess(consumerModel, "ConsumerProcess", "ConsumerProcess");
+ ProcessDefinitionType providedProcess = facade.createProcess(providerModel, "ProvidedProcess", "ProvidedProcess");
+ ProcessDefinitionType providedProcess2 = facade.createProcess(providerModel, "ProvidedProcess2", "ProvidedProcess2");
+ ProcessDefinitionType consumerProcess = facade.createProcess(consumerModel, "ConsumerProcess", "ConsumerProcess");
//Structured Data / Document Data
- MBFacade.getInstance().createStructuredData(providerModel, "LocalComposite1", "LocalComposite1", "ProviderModel:ProvidedComposite");
- MBFacade.getInstance().createStructuredData(consumerModel, "ProvidedComposite1", "ProvidedComposite1", "ProviderModel:ProvidedComposite");
- MBFacade.getInstance().createDocumentData(providerModel, "LocalDocument", "LocalDocument", "ProvidedComposite");
+ facade.createStructuredData(providerModel, "LocalComposite1", "LocalComposite1", "ProviderModel:ProvidedComposite");
+ facade.createStructuredData(consumerModel, "ProvidedComposite1", "ProvidedComposite1", "ProviderModel:ProvidedComposite");
+ facade.createDocumentData(providerModel, "LocalDocument", "LocalDocument", "ProvidedComposite");
//Applications
- MBFacade.getInstance().createApplication(providerModel, "WebService", "WebService", ModelerConstants.WEB_SERVICE_APPLICATION_TYPE_ID);
+ facade.createApplication(providerModel, "WebService", "WebService", ModelerConstants.WEB_SERVICE_APPLICATION_TYPE_ID);
//Activities
- MBFacade.getInstance().createActivity(providerModel, providedProcess2, "Manual", "ProviderModel:Administrator", "ManualActivity1", "ManualActivity1", null, null);
- MBFacade.getInstance().createActivity(providerModel, providedProcess2, "Application", null, "AppActivity1", "AppActivity1", "ProviderModel:WebService", null);
- MBFacade.getInstance().createActivity(consumerModel, consumerProcess, "Subprocess", null, "ProvidedProcess1", "ProvidedProcess1", null, "ProviderModel:ProvidedProcess");
+ facade.createActivity(providerModel, providedProcess2, "Manual", "ProviderModel:Administrator", "ManualActivity1", "ManualActivity1", null, null);
+ facade.createActivity(providerModel, providedProcess2, "Application", null, "AppActivity1", "AppActivity1", "ProviderModel:WebService", null);
+ facade.createActivity(consumerModel, consumerProcess, "Subprocess", null, "ProvidedProcess1", "ProvidedProcess1", null, "ProviderModel:ProvidedProcess");
//Store
byte[] modelContent = XpdlModelIoUtils.saveModel(providerModel);