View Javadoc

1   /**
2    * Copyright 2007 Björn Voß
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * 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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package net.sf.oxclient.service.client.impl;
17  
18  import java.util.Map;
19  
20  import net.sf.oval.constraint.NotNull;
21  import net.sf.oval.guard.Guarded;
22  import net.sf.oxclient.IUser;
23  import net.sf.oxclient.beans.Folder;
24  import net.sf.oxclient.service.AbsGroupwareModule;
25  import net.sf.oxclient.service.AbsGroupwareSession;
26  import net.sf.oxclient.service.AbsGroupwareSessionFactory;
27  import net.sf.oxclient.service.client.IOXSession;
28  import net.sf.oxclient.service.client.IOXSessionFactory;
29  
30  import org.springframework.beans.BeansException;
31  import org.springframework.beans.factory.BeanFactory;
32  import org.springframework.beans.factory.BeanFactoryAware;
33  
34  /**
35   * @author Björn Voß
36   *
37   */
38  @Guarded
39  public class OXGroupwareSessionFactory extends
40  	AbsGroupwareSessionFactory<Folder> implements IOXSessionFactory,
41  	BeanFactoryAware {
42  
43      private String moduleMapName = "moduleMap";
44      private String serverUrl;
45  
46      private BeanFactory beanFactory = null;
47  
48  
49  
50      /* (non-Javadoc)
51  	 * @see net.sf.oxclient.service.AbsGroupwareSessionFactory#login(net.sf.oxclient.IUser)
52  	 */
53  	@Override
54  	public IOXSession login(final IUser user) {
55  		return (IOXSession) super.login(user);
56  	}
57  
58  	/*
59       * (non-Javadoc)
60       *
61       * @see net.sf.oxclient.service.AbsGroupwareService#getModuleMap(net.sf.oxclient.IUser)
62       */
63      @SuppressWarnings("unchecked")
64      @Override
65      public Map<String, AbsGroupwareModule<?, Folder>> getModuleMap(
66  	    final IUser user) {
67  	return (Map<String, AbsGroupwareModule<?, Folder>>) this.beanFactory
68  		.getBean(this.moduleMapName);
69      }
70  
71      /*
72       * (non-Javadoc)
73       *
74       * @see net.sf.oxclient.service.AbsGroupwareService#getNewGourpwareSession(net.sf.oxclient.IUser)
75       */
76      @SuppressWarnings("unchecked")
77      @Override
78      public AbsGroupwareSession<Folder> getNewGourpwareSession(final IUser user) {
79  	final AbsGroupwareSession<Folder> result =
80  	    (AbsGroupwareSession<Folder>) this.beanFactory
81  		.getBean("groupwareSession");
82  	result.getCommunicationManager().setOXServerURL(this.serverUrl);
83  	return result;
84      }
85  
86      /*
87       * (non-Javadoc)
88       *
89       * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
90       */
91      public void setBeanFactory(@NotNull final BeanFactory beanFactory)
92      		throws BeansException {
93  	this.beanFactory = beanFactory;
94      }
95  
96      /**
97       * @param moduleMapName
98       *                the moduleMapName to set
99       */
100     public void setModuleMapName(final String moduleMapName) {
101 	this.moduleMapName = moduleMapName;
102     }
103 
104     /*
105      * (non-Javadoc)
106      *
107      * @see net.sf.oxclient.service.client.IOXSessionFactory#getOXServerURL()
108      */
109     public String getServerURL() {
110 	return this.serverUrl;
111     }
112 
113     /*
114      * (non-Javadoc)
115      *
116      * @see net.sf.oxclient.service.client.IOXSessionFactory#setOXServerURL(java.lang.String)
117      */
118     public void setServerURL(final String server) {
119     	this.serverUrl = server;
120     }
121 }