KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > DriverManager


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/DriverManager.java#23 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2002-2002 Kana Software, Inc.
7 // Copyright (C) 2002-2006 Julian Hyde and others
8 // All Rights Reserved.
9 // You must accept the terms of that agreement to use this software.
10 //
11 // jhyde, 15 January, 2002
12 */

13
14 package mondrian.olap;
15 import mondrian.rolap.RolapConnection;
16 import mondrian.rolap.RolapConnectionProperties;
17 import mondrian.spi.CatalogLocator;
18 import mondrian.spi.impl.CatalogLocatorImpl;
19
20 import javax.sql.DataSource JavaDoc;
21
22 /**
23  * The basic service for managing a set of OLAP drivers.
24  *
25  * @author jhyde
26  * @since 15 January, 2002
27  * @version $Id: //open/mondrian/src/main/mondrian/olap/DriverManager.java#23 $
28  */

29 public class DriverManager {
30
31     public DriverManager() {
32     }
33
34     /**
35      * Creates a connection to a Mondrian OLAP Server.
36      *
37      * @param connectString Connect string of the form
38      * 'property=value;property=value;...'.
39      * See {@link Util#parseConnectString} for more details of the format.
40      * See {@link mondrian.rolap.RolapConnectionProperties} for a list of
41      * allowed properties.
42      * @param locator Use to locate real catalog url by a customized
43      * configuration value. If <code>null</code>, leave the catalog url
44      * unchanged.
45      * @param fresh If <code>true</code>, a new connection is created;
46      * if <code>false</code>, the connection may come from a connection pool.
47      * @return A {@link Connection}
48      * @post return != null
49      */

50     public static Connection getConnection(
51             String JavaDoc connectString,
52             CatalogLocator locator,
53             boolean fresh) {
54         Util.PropertyList properties = Util.parseConnectString(connectString);
55         return getConnection(properties, locator, fresh);
56     }
57
58     /**
59      * Creates a connection to a Mondrian OLAP Server.
60      *
61      * @deprecated Use {@link #getConnection(mondrian.olap.Util.PropertyList, mondrian.spi.CatalogLocator, boolean)}
62      */

63     public static Connection getConnection(
64             Util.PropertyList properties,
65             boolean fresh) {
66         return getConnection(properties, CatalogLocatorImpl.INSTANCE, fresh);
67     }
68
69     /**
70      * Creates a connection to a Mondrian OLAP Server.
71      *
72      * @param properties Collection of properties which define the location
73      * of the connection.
74      * See {@link RolapConnection} for a list of allowed properties.
75      * @param locator Use to locate real catalog url by a customized
76      * configuration value. If <code>null</code>, leave the catalog url
77      * unchanged.
78      * @param fresh If <code>true</code>, a new connection is created;
79      * if <code>false</code>, the connection may come from a connection pool.
80      * @return A {@link Connection}
81      * @post return != null
82      */

83     public static Connection getConnection(
84             Util.PropertyList properties,
85             CatalogLocator locator,
86             boolean fresh) {
87         return getConnection(properties, locator, null, fresh);
88     }
89
90     /**
91      * Creates a connection to a Mondrian OLAP Server.
92      *
93      * @param properties Collection of properties which define the location
94      * of the connection.
95      * See {@link RolapConnection} for a list of allowed properties.
96      * @param locator Use to locate real catalog url by a customized
97      * configuration value. If <code>null</code>, leave the catalog url
98      * unchanged.
99      * @param dataSource - if not null an external DataSource to be used
100      * by Mondrian
101      * @param fresh If <code>true</code>, a new connection is created;
102      * if <code>false</code>, the connection may come from a connection pool.
103      * @return A {@link Connection}
104      * @post return != null
105      */

106     public static Connection getConnection(
107             Util.PropertyList properties,
108             CatalogLocator locator,
109             DataSource JavaDoc dataSource,
110             boolean fresh) {
111         String JavaDoc provider = properties.get("PROVIDER", "mondrian");
112         if (!provider.equalsIgnoreCase("mondrian")) {
113             throw Util.newError("Provider not recognized: " + provider);
114         }
115         if (locator != null) {
116             String JavaDoc catalog = properties.get(
117                 RolapConnectionProperties.Catalog.name());
118             properties.put(
119                 RolapConnectionProperties.Catalog.name(),
120                 locator.locate(catalog));
121         }
122         return new RolapConnection(properties, dataSource);
123     }
124 }
125
126
127 // End DriverManager.java
128
Popular Tags