KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencrx > kernel > client > ClientHelper


1 package org.opencrx.kernel.client;
2
3
4 import java.util.ArrayList JavaDoc;
5 import java.util.List JavaDoc;
6
7 import javax.naming.Context JavaDoc;
8 import javax.naming.NamingException JavaDoc;
9
10 import org.openmdx.base.accessor.generic.cci.ObjectFactory_1_0;
11 import org.openmdx.base.accessor.generic.view.Manager_1;
12 import org.openmdx.base.accessor.jmi.cci.RefPackage_1_0;
13 import org.openmdx.base.exception.ServiceException;
14 import org.openmdx.compatibility.base.dataprovider.cci.QualityOfService;
15 import org.openmdx.compatibility.base.dataprovider.cci.RequestCollection;
16 import org.openmdx.compatibility.base.dataprovider.cci.ServiceHeader;
17 import org.openmdx.compatibility.base.dataprovider.transport.adapter.Provider_1;
18 import org.openmdx.compatibility.base.dataprovider.transport.cci.Dataprovider_1ConnectionFactory;
19 import org.openmdx.compatibility.base.dataprovider.transport.cci.Dataprovider_1_1Connection;
20 import org.openmdx.compatibility.base.dataprovider.transport.cci.Provider_1_0;
21 import org.openmdx.compatibility.base.dataprovider.transport.delegation.Connection_1;
22
23 public class ClientHelper {
24
25     //-----------------------------------------------------------------------
26
public static ObjectFactory_1_0 createObjectFactory(
27         Context JavaDoc componentEnvironment,
28         String JavaDoc name
29     ) throws ServiceException, NamingException JavaDoc {
30         Dataprovider_1ConnectionFactory f = (Dataprovider_1ConnectionFactory)componentEnvironment.lookup(name);
31         Dataprovider_1_1Connection connection = f.createConnection();
32         Provider_1_0 provider = new Provider_1(
33             new RequestCollection(
34                 new ServiceHeader(DEFAULT_PRINCIPAL_NAME, null, false, new QualityOfService()),
35                 connection
36             ),
37             false
38         );
39         return new Manager_1(
40             new Connection_1(
41                 provider,
42                 false,
43                 null
44             )
45         );
46     }
47
48     //-----------------------------------------------------------------------
49
public static void loadModels(
50         Context JavaDoc componentEnvironment,
51         RefPackage_1_0 rootPkg
52     ) throws ServiceException {
53         List JavaDoc modelPackages = new ArrayList JavaDoc();
54         int i = 0;
55         while(true) {
56             try {
57                 String JavaDoc modelPackage = (String JavaDoc)componentEnvironment.lookup("modelPackage[" + i + "]");
58                 modelPackages.add(modelPackage);
59             }
60             catch(NamingException JavaDoc e) {
61                 break;
62             }
63             i++;
64         }
65         rootPkg.refModel().addModels(modelPackages);
66     }
67
68     private static final String JavaDoc DEFAULT_PRINCIPAL_NAME = "guest";
69     
70 }
71
72 //--- End of File -----------------------------------------------------------
73
Popular Tags