This page last changed on Mar 13, 2008.
How To Access Catalog Services
Catalog services provide a convenient way for client-application developers to programmatically obtain information about ALDSP artifacts(dataspaces, data services, schemas, functions and relationships). Catalog Services are also data services. This allows the client application developer to access catalog services as they would any other data service. This section provides details about installing and using Catalog Services to access metadata for any ALDSP dataspace. TopicsWhat this How-To DemonstratesThis how-to describes:
BackgroundBefore you read through the next section, ensure that you have an understanding on how data services can be accessed from Java clients.
Installing Catalog ServicesCatalog Service data services are installed inside an existing dataspace project. Once installed, the catalog services folder (_catalogservices) contains data services that can be used to fetch metadata about dataspace project artifacts. To install Catalog Services right-click any dataspace project and select Install Catalog Services. The following data services will be created in the project's _catalogservices folder:
Accessing Catalog ServicesCatalog Services data services can be accessed through the ALDSP mediator API dynamic or static interface. Accessing Catalog Service Information DynamicallyThe following sample demonstrates how to access the "getDataServiceRefs" function of a data service named DataService dynamically. public class SampleCS { public static Context createContext() throws NamingException { Hashtable ctxTable = new Hashtable(); ctxTable.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); ctxTable.put(Context.PROVIDER_URL, "t3://localhost:7001"); ctxTable.put(Context.SECURITY_PRINCIPAL, "weblogic"); ctxTable.put(Context.SECURITY_CREDENTIALS, "weblogic"); return new InitialContext(ctxTable); } public static void main(String[] args) throws Exception { Context context = createContext(); String dsName = "ld:_catalogservices/DataService"; // Line #3 String appName = "PublicMetadataAPI"; DataAccessService das = DataAccessServiceFactory.newDataAccessService(context, appName, dsName); DASResult<Object> dasResult = das.invoke("getDataServiceRefs", null); //Line #2 while (dasResult.hasNext()) { DataObjectGeneral dObjGeneral = (DataObjectGeneral) dasResult.next(); DataObject dObject = dObjGeneral.getRootObject(); String id = (String) dObject.get("id"); //Line#3 System.out.println("ID = " + id); } } In the above code there are several lines marked with comments and associated with numbers.
Compiling and Running the sample. Compile and run the sample with the client classpath. Accessing Catalog Service Information StaticallyCreate the Mediator Client JAR File through these steps:
The following sample demonstrates how to access the "getDataServiceRefs" function of the "DataService" DS statically: public class StaticCS { public static Context createContext() throws NamingException { Hashtable ctxTable = new Hashtable(); ctxTable.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); ctxTable.put(Context.PROVIDER_URL, "t3://localhost:7001"); ctxTable.put(Context.SECURITY_PRINCIPAL, "weblogic"); ctxTable.put(Context.SECURITY_CREDENTIALS, "weblogic"); return new InitialContext(ctxTable); } public static void main(String[] args) throws Exception { Context context = createContext(); String appName = "PublicMetadataAPI"; DataServiceDAS das = DataServiceDAS.getInstance(createContext(),appName); //Line #1 DASResult<DataServiceRef> result = das.getDataServiceRefs(); //Line #2 while (result.hasNext()) { DataServiceRef ref = result.next(); //Line #3 System.out.println("ref.getId() = " + ref.getId()); } } } In the above code, Line #3 shows the casting of the result to the specific type: i.e. DataServiceRef instead of the generic DataObject. Compile and run the sample with the client classpath. Additional References, Considerations, and Caveats
![]() ![]() ![]() ![]() |
![]() |
Document generated by Confluence on Apr 28, 2008 16:27 |