1 package org.opencrx.kernel.client; 2 3 4 import java.util.ArrayList ; 5 import java.util.List ; 6 7 import javax.naming.Context ; 8 import javax.naming.NamingException ; 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 public static ObjectFactory_1_0 createObjectFactory( 27 Context componentEnvironment, 28 String name 29 ) throws ServiceException, NamingException { 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 public static void loadModels( 50 Context componentEnvironment, 51 RefPackage_1_0 rootPkg 52 ) throws ServiceException { 53 List modelPackages = new ArrayList (); 54 int i = 0; 55 while(true) { 56 try { 57 String modelPackage = (String )componentEnvironment.lookup("modelPackage[" + i + "]"); 58 modelPackages.add(modelPackage); 59 } 60 catch(NamingException e) { 61 break; 62 } 63 i++; 64 } 65 rootPkg.refModel().addModels(modelPackages); 66 } 67 68 private static final String DEFAULT_PRINCIPAL_NAME = "guest"; 69 70 } 71 72 | Popular Tags |