Source Code Cross Referenced for DefaultClientInitializer.java in  » Workflow-Engines » osbl-1_0 » org » osbl » client » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » osbl 1_0 » org.osbl.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.osbl.client;
002:
003:        import org.osbl.client.action.ActionProvider;
004:        import org.osbl.client.action.StaticActionProvider;
005:        import org.osbl.client.ClientResourceProvider;
006:        import org.osbl.client.ClientServiceProvider;
007:        import org.osbl.client.wings.devtools.*;
008:        import org.osbl.client.wings.navigation.Navigation;
009:        import org.osbl.client.wings.navigation.NavigationStructure;
010:        import org.osbl.client.wings.concern.Overview;
011:        import org.osbl.client.wings.shell.*;
012:        import org.osbl.plugin.*;
013:        import org.osbl.JTAHibernateEnvironment;
014:        import org.osbl.ServiceProvider;
015:        import org.osbl.persistence.*;
016:        import org.osbl.authorization.Authorization;
017:        import org.conform.BeanMetaProvider;
018:        import org.conform.format.FormatFactory;
019:        import org.conform.format.ResourceProvider;
020:        import org.conform.wings.ComponentFactory;
021:        import org.conform.wings.DefaultEditorFactory; //import org.osbl.client.wings.devtools.AjaxDebugDevTool;
022:        import org.hibernate.SessionFactory;
023:        import org.wings.SConstants;
024:        import org.wings.SLabel;
025:        import org.wings.event.*;
026:        import org.wings.session.Session;
027:        import org.wings.session.SessionManager;
028:
029:        import javax.transaction.TransactionManager;
030:        import javax.swing.*;
031:        import java.util.*;
032:
033:        public class DefaultClientInitializer implements  ClientInitializer {
034:            public void preInitialization(Client client) {
035:                final Session session = SessionManager.getSession();
036:
037:                ClientServiceProvider serviceProvider = ClientServiceProvider
038:                        .getInstance();
039:                client.setServiceProvider(serviceProvider);
040:
041:                ClientResourceProvider resourceProvider = (ClientResourceProvider) serviceProvider
042:                        .getService("ClientResourceProvider");
043:                client.setResourceProvider(resourceProvider);
044:
045:                determineLocale(resourceProvider);
046:
047:                FormatFactory.getInstance().setLocale(session.getLocale());
048:                SessionManager.getSession().addRequestListener(
049:                        new SRequestListener() {
050:                            public void processRequest(SRequestEvent e) {
051:                                switch (e.getType()) {
052:                                case SRequestEvent.REQUEST_START:
053:                                    FormatFactory.getInstance().setLocale(
054:                                            session.getLocale());
055:                                    break;
056:                                case SRequestEvent.REQUEST_END:
057:                                    FormatFactory.getInstance().setLocale(null);
058:                                    break;
059:                                }
060:                            }
061:                        });
062:
063:                BeanMetaProvider staticBeanMetaProvider = (BeanMetaProvider) serviceProvider
064:                        .getService("StaticBeanMetaProvider");
065:                BeanMetaProvider webappBeanMetaProvider = new WebappBeanMetaProvider(
066:                        staticBeanMetaProvider);
067:                BeanMetaProvider sessionMetaProvider = new SessionBeanMetaProvider(
068:                        webappBeanMetaProvider);
069:                client.setBeanMetaProvider(sessionMetaProvider);
070:
071:                ActionProvider actionProvider = new SessionActionProvider(
072:                        StaticActionProvider.INSTANCE);
073:                client.setActionProvider(actionProvider);
074:
075:                DefaultEditorFactory editorFactory = new DefaultEditorFactory();
076:                registerEditors(editorFactory);
077:                ComponentFactory.INSTANCE.setEditorFactory(editorFactory);
078:                ComponentFactory.INSTANCE.setResourceProvider(resourceProvider);
079:
080:                try {
081:                    JTAHibernateEnvironment environment = new JTAHibernateEnvironment();
082:                    environment
083:                            .setTransactionManager((TransactionManager) serviceProvider
084:                                    .getService("TransactionManager"));
085:                    environment
086:                            .setSessionFactory((SessionFactory) serviceProvider
087:                                    .getService("SessionFactory"));
088:                    JTAHibernateEnvironmentRequestListener listener = new JTAHibernateEnvironmentRequestListener(
089:                            environment);
090:                    listener.processRequest(new SRequestEvent(session,
091:                            SRequestEvent.REQUEST_START, null));
092:                } catch (Exception e) {
093:                    e.printStackTrace();
094:                }
095:            }
096:
097:            private void registerEditors(DefaultEditorFactory editorFactory) {
098:            }
099:
100:            public void postInitialization(Client client) {
101:                SLabel label = new SLabel();
102:                label.setStyle(label.getStyle() + " headerlabel");
103:                label.setVerticalAlignment(SConstants.CENTER_ALIGN);
104:                client.addHeaderComponent(label);
105:
106:                ActionProvider actionProvider = client.getActionProvider();
107:                client.addHeaderButton(actionProvider
108:                        .getAction("businessobject.actions.logout"));
109:
110:                Navigation navigation = new Navigation();
111:                navigation.setModel(NavigationStructure.getInstance()
112:                        .generateTree());
113:
114:                client.addNavigation("navigation", client.getResourceProvider()
115:                        .getMessage("navigation.navigation"), null, navigation);
116:                client.addNavigation("overview", client.getResourceProvider()
117:                        .getMessage("navigation.overview"), null,
118:                        new Overview());
119:
120:                // Check whether the development tools are activated.
121:                boolean developmentToolsActivated = Boolean
122:                        .valueOf((String) SessionManager.getSession()
123:                                .getProperty("development.tools", "false"));
124:                if (developmentToolsActivated) {
125:                    DevelopmentTool developmentTool = new DevelopmentTool();
126:
127:                    PluginManager pluginManager = (PluginManager) ClientServiceProvider
128:                            .getInstance().getService("ClientPluginManager");
129:                    final ExtensionPoint extensionPoint = new ExtensionPoint(
130:                            "org.osbl.client.wings.devtools", Action.class);
131:                    final List<Extension> list = pluginManager
132:                            .getExtensions(extensionPoint);
133:                    List<Action> actions = new ArrayList<Action>();
134:                    for (Extension extension : list) {
135:                        final Class<Action> actionClass = (Class<Action>) extension
136:                                .getImplementation();
137:                        try {
138:                            actions.add(actionClass.newInstance());
139:                        } catch (Exception e) {
140:                            e.printStackTrace();
141:                        }
142:                    }
143:                    developmentTool.setGlobalActions(actions
144:                            .toArray(new Action[actions.size()]));
145:                    client.setDevelopmentTool(developmentTool);
146:                }
147:                client.setContextHelpTool(new ContextHelpTool());
148:
149:                SessionManager.getSession().addExitListener(new ExitListener());
150:            }
151:
152:            private String buildLabel(String lastName, String firstName,
153:                    String mandatorKey) {
154:                StringBuilder sb = new StringBuilder();
155:                boolean lastNameIsNull = lastName == null
156:                        || lastName.trim().length() == 0;
157:                boolean firstNameIsNull = firstName == null
158:                        || firstName.trim().length() == 0;
159:                if (!lastNameIsNull)
160:                    sb.append(lastName);
161:
162:                if (!lastNameIsNull && !firstNameIsNull)
163:                    sb.append(", ");
164:
165:                if (!firstNameIsNull)
166:                    sb.append(firstName);
167:
168:                sb.append(" (").append(mandatorKey).append(")");
169:
170:                return sb.toString();
171:            }
172:
173:            private void determineLocale(ResourceProvider resourceProvider) {
174:                SessionManager.getSession().setSupportedLocales(
175:                        resourceProvider.getSupportedLocales().toArray(
176:                                new Locale[0]));
177:                SessionManager.getSession().setLocaleFromHeader(false);
178:            }
179:
180:            private static class ExitListener implements  SExitListener {
181:                private String userid;
182:
183:                public ExitListener() {
184:                    userid = SessionManager.getSession().getServletRequest()
185:                            .getUserPrincipal().getName();
186:                }
187:
188:                public void prepareExit(SExitEvent e) throws ExitVetoException {
189:                    Authorization authorization = (Authorization) ServiceProvider
190:                            .getInstance().getService("AuthorizationService");
191:                    authorization.clearCache(userid);
192:                }
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.