01: package org.drools.brms.server.files;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import javax.servlet.http.HttpServlet;
20:
21: import org.apache.log4j.Logger;
22: import org.drools.brms.server.util.TestEnvironmentSessionHelper;
23: import org.drools.repository.RulesRepository;
24: import org.jboss.seam.Component;
25: import org.jboss.seam.contexts.Contexts;
26:
27: /**
28: * This is a base servlet that all repo servlets inherit behaviour from.
29: *
30: * @author Michael Neale
31: */
32: public class RepositoryServlet extends HttpServlet {
33:
34: private static final long serialVersionUID = 400L;
35: // protected final FileManagerUtils uploadHelper = new FileManagerUtils();
36: public static final Logger log = Logger
37: .getLogger(RepositoryServlet.class);
38:
39: // protected RulesRepository getRepository() {
40: //
41: // if ( Contexts.isApplicationContextActive() ) {
42: // return (RulesRepository) Component.getInstance( "repository" );
43: // } else {
44: // //MN: NOTE THIS IS MY HACKERY TO GET IT WORKING IN GWT HOSTED MODE.
45: // //THIS IS ALL THAT IS NEEDED FOR THE SERVLETS.
46: // log.debug( "WARNING: RUNNING IN NON SEAM MODE SINGLE USER MODE - ONLY FOR TESTING AND DEBUGGING !!!!!" );
47: //
48: // try {
49: // return new RulesRepository( TestEnvironmentSessionHelper.getSession( false ) );
50: // } catch ( Exception e ) {
51: // throw new IllegalStateException( "Unable to launch debug mode..." );
52: // }
53: // }
54: // }
55:
56: public FileManagerUtils getFileManager() {
57: if (Contexts.isApplicationContextActive()) {
58: return (FileManagerUtils) Component
59: .getInstance("fileManager");
60: } else {
61: //MN: NOTE THIS IS MY HACKERY TO GET IT WORKING IN GWT HOSTED MODE.
62: //THIS IS ALL THAT IS NEEDED FOR THE SERVLETS.
63: log
64: .debug("WARNING: RUNNING IN NON SEAM MODE SINGLE USER MODE - ONLY FOR TESTING AND DEBUGGING !!!!!");
65: FileManagerUtils manager = new FileManagerUtils();
66: try {
67: manager.repository = new RulesRepository(
68: TestEnvironmentSessionHelper.getSession(false));
69: return manager;
70: } catch (Exception e) {
71: throw new IllegalStateException();
72: }
73:
74: }
75: }
76:
77: }
|