Accessing Metamodel from Java program
In Brief
- From your own java code access Model repository as follows:
import javax.naming.Context;
import javax.naming.InitialContext;
import com.metaboss.sdlctools.models.ModelRepository;
Context lContext = new javax.naming.InitialContext();
ModelRepository lModelRepository = (ModelRepository)lContext.lookup(ModelRepository.COMPONENT_URL);
- To open existing enterprise model:
import java.io.File;
import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
File lModelFile = new File("c:/SampleModel/Model.xml");
lModelRepository.openModel("SampleEnterpriseModel",lModelFile,"MetaBossMetaModel", null);
MetaBossModelPackage lModelPackage = (MetaBossModelPackage)lModelRepository.getModelExtent("SampleEnterpriseModel");
Enterprise lEnterprise = (Enterprise)lMetaBossModelPackage.getModelElement().getByRef("Enterprise");
- Include following jars into the classpath of the running application:
${metaboss_home}/lib/MetaBossCore.jar | MetaBoss core utilities library |
${metaboss_home}/lib/MetaBossComponentNamingProvider.jar | MetaBoss component naming engine library |
${metaboss_home}/lib/MetaBossEnterprise.jar | MetaBoss enterprise components frameworkk library |
${metaboss_home}/lib/MetaBossModel.jar | MetaBoss design model access library |
${metaboss_home}/thirdpartylib/commons-logging-1.0.3.jar | Apache Commons Logging abstraction library |
${metaboss_home}/thirdpartylib/log4j-1.2.8.jar | Apache Log4j library |
${metaboss_home}/thirdpartylib/netbeansmdr-20040212/jmi.jar | Part of NetBeans MDR framework |
${metaboss_home}/thirdpartylib/netbeansmdr-20040212/jmiutils.jar | Part of NetBeans MDR framework |
${metaboss_home}/thirdpartylib/netbeansmdr-20040212/mdrapi.jar | Part of NetBeans MDR framework |
${metaboss_home}/thirdpartylib/netbeansmdr-20040212/mof.jar | Part of NetBeans MDR framework |
${metaboss_home}/thirdpartylib/netbeansmdr-20040212/nbmdr.jar | Part of NetBeans MDR framework |
${metaboss_home}/thirdpartylib/netbeansmdr-20040212/openide-util.jar | Part of NetBeans MDR framework |
- Set the MetaBoss.Home Java system property to point to the top level installation directory of MetaBoss. (eg. use -D command line VM argument)
- You may want to use log4j.properties file similar to the one below if you want to see debug information coming out of the MetaBoss libraries:
log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Additional Notes
The MetaBoss metamodel repository is a storage mechanism for enterprise metadata.
It is being edited with use of MetaBoss Design Studio and it is being read by practically
every generator in MetaBoss suite.
The MetaBoss metamodel repository is based on MDR (stands for Metadata Repository) library, which is a subproject
of the NetBeans project. The MDR is really a reference implementation of the
JMI (stands for Java Metadata Interchange) standard, which in turn is based on MOF (stands for Meta Object Facility)
standard published by OMG.
MetaBoss repository has a few important features not present so far in MDR framework:
- Ability to define directory tree structure for the models and save and retrieve files in accordance with
this definition. MDR has theoretical ability to save and read multiple XMI files, but MetaBoss repository is more
sutable for practitioners. For example it only saves files, which have been changed.
- Ability to attach file to any element of the model. This feature somehow is not part of current
JMI/MOF standards, but again it is very useful for practitioners.
It is, of course our intention to retire MetaBoss's extra features as soon as MDR/JMI/MOF will
provide something similar.
Typically application, which wants to use metamodel will lookup com.metaboss.sdlctools.models.ModelRepository component via JNDI, open or create
model storage and navigate around model elements to complete its job. The repository can hold
any number of instances of the model. It can also hold instances of the different models.
At run time such application needs to include some java libraries and set some system propertries, so MetaBoss metamodel access
library can have everything it needs to find and use the model files.
References
To find out more about MDR, JMI and MOF use following links:
|
Copyright © 2000-2005 Softaris Pty.Ltd. All Rights Reserved. MetaBoss is the registered trademark of Softaris Pty.Ltd. Java, Enterprise JavaBeans, JDBC, JNDI, JTA, JTS, JCA and other Java related APIs are trademarks or registered trademarks of Sun Microsystems, Inc. MDA, UML, MOF, CORBA and IIOP are trademarks or registered trademarks of the Object Management Group. Microsoft, .NET and C# are trademarks or registered trademarks of the Microsoft Corporation. All other product names mentioned herein are trademarks of their respective owners.
|