1 45 package org.exolab.jms.config; 46 47 import javax.naming.Context ; 48 49 import org.exolab.jms.config.types.SchemeType; 50 51 52 60 public class JndiConfigurationFactory { 61 62 71 public static JndiConfiguration create(Configuration config) { 72 if (config == null) { 73 throw new IllegalArgumentException ("Argument config is null"); 74 } 75 JndiConfiguration result = new JndiConfiguration(); 76 77 Connectors connectors = config.getConnectors(); 78 Connector connector = connectors.getConnector(0); 79 return create(connector, config); 80 } 81 82 91 public static JndiConfiguration create(Connector connector, 92 Configuration config) { 93 if (connector == null) { 94 throw new IllegalArgumentException ("Argument connector is null"); 95 } 96 if (config == null) { 97 throw new IllegalArgumentException ("Argument config is null"); 98 } 99 JndiConfiguration result = new JndiConfiguration(); 100 101 ServerConfiguration server = config.getServerConfiguration(); 102 SchemeType scheme = connector.getScheme(); 103 ConnectorResource resource = ConnectorHelper.getConnectorResource( 104 scheme, config); 105 106 Property context = new Property(); 107 context.setName(Context.INITIAL_CONTEXT_FACTORY); 108 context.setValue(resource.getJndi().getInitialContextClass()); 109 result.addProperty(context); 110 111 Property url = new Property(); 112 url.setName(Context.PROVIDER_URL); 113 url.setValue(ConfigHelper.getJndiURL(scheme, config)); 114 result.addProperty(url); 115 return result; 116 } 117 118 } | Popular Tags |