View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.jdiagnose.library.db;
17  
18  import net.sf.hibernate.SessionFactory;
19  
20  import org.jdiagnose.remote.system.Query;
21  import org.jdiagnose.remote.system.RemoteDataServiceSystem;
22  import org.jdiagnose.remote.system.RemoteSystem;
23  import org.jdiagnose.remote.system.RemoteSystemCreator;
24  
25  /***
26   * @author jmccrindle
27   */
28  public class HibernateRemoteSystemCreator implements RemoteSystemCreator {
29  
30      private SessionFactory sessionFactory = null;
31      
32      /* (non-Javadoc)
33       * @see org.jdiagnose.remote.system.RemoteSystemCreator#getRemoteSystem(org.jdiagnose.remote.system.Query)
34       */
35      public RemoteSystem getRemoteSystem(Query query) {
36          HibernateRemoteDataService dataService = new HibernateRemoteDataService(query);
37          dataService.setSessionFactory(sessionFactory);
38          return new RemoteDataServiceSystem(dataService);
39      }
40  
41      public void setSessionFactory(SessionFactory sessionFactory) {
42          this.sessionFactory = sessionFactory;
43      }
44  }