Source Code Cross Referenced for Management.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » server » admin » 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 » EJB Server resin 3.1.5 » resin » com.caucho.server.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Scott Ferguson
028:         */
029:
030:        package com.caucho.server.admin;
031:
032:        import com.caucho.config.ConfigException;
033:        import com.caucho.config.types.RawString;
034:        import com.caucho.lifecycle.*;
035:        import com.caucho.server.cluster.Cluster;
036:        import com.caucho.server.cluster.DeployManagementService;
037:        import com.caucho.server.cluster.Server;
038:        import com.caucho.server.host.HostConfig;
039:        import com.caucho.server.resin.*;
040:        import com.caucho.security.*;
041:        import com.caucho.server.security.*;
042:        import com.caucho.webbeans.manager.*;
043:        import com.caucho.util.L10N;
044:        import com.caucho.vfs.Path;
045:
046:        import javax.annotation.*;
047:        import javax.resource.spi.ResourceAdapter;
048:        import javax.webbeans.*;
049:        import java.util.logging.Logger;
050:
051:        /**
052:         * Configuration for management.
053:         */
054:        public class Management {
055:            private static L10N L = new L10N(Management.class);
056:            private static Logger log = Logger.getLogger(Management.class
057:                    .getName());
058:
059:            public static final String HOST_NAME = "admin.caucho";
060:
061:            private Cluster _cluster;
062:            private Resin _resin;
063:            private Server _server;
064:            private Path _path;
065:
066:            private HostConfig _hostConfig;
067:
068:            private ManagementAuthenticator _auth;
069:
070:            private DeployManagementService _deployService;
071:            protected TransactionManager _transactionManager;
072:
073:            private Lifecycle _lifecycle = new Lifecycle();
074:
075:            public void setCluster(Cluster cluster) {
076:                _cluster = cluster;
077:            }
078:
079:            public void setResin(Resin resin) {
080:                _resin = resin;
081:            }
082:
083:            public void setServer(Server server) {
084:                _server = server;
085:            }
086:
087:            public String getServerId() {
088:                return Cluster.getServerId();
089:            }
090:
091:            /**
092:             * Sets the path for storing managment related logs and files,
093:             * default is "admin".
094:             */
095:            public void setPath(Path path) {
096:                _path = path;
097:            }
098:
099:            public Path getPath() {
100:                return _path;
101:            }
102:
103:            /**
104:             * Adds a user
105:             */
106:            public void addUser(User user) {
107:                if (_auth == null)
108:                    _auth = new ManagementAuthenticator();
109:
110:                _auth.addUser(user.getName(), user.getPasswordUser());
111:            }
112:
113:            /**
114:             * Returns the management cookie.
115:             */
116:            public String getRemoteCookie() {
117:                if (_auth != null)
118:                    return _auth.getHash();
119:                else
120:                    return null;
121:            }
122:
123:            /**
124:             * Create and configure the j2ee deploy service.
125:             */
126:            public DeployManagementService createDeployService() {
127:                if (_deployService == null)
128:                    _deployService = new DeployManagementService(this );
129:
130:                return _deployService;
131:            }
132:
133:            /**
134:             * Create and configure the jmx service.
135:             */
136:            public Object createJmxService() {
137:                throw new ConfigException(L
138:                        .l("jmx-service requires Resin Professional"));
139:            }
140:
141:            /**
142:             * Create and configure the ping monitor.
143:             */
144:            public ResourceAdapter createPing() {
145:                throw new ConfigException(L
146:                        .l("ping requires Resin Professional"));
147:            }
148:
149:            public void addPing(ResourceAdapter ping) {
150:                throw new ConfigException(L
151:                        .l("ping requires Resin Professional"));
152:            }
153:
154:            /**
155:             * Create and configure the persistent logger.
156:             */
157:            public Object createLogService() {
158:                throw new ConfigException(
159:                        L
160:                                .l("'log-service' management requires Resin Professional"));
161:            }
162:
163:            /**
164:             * Create and configure the transaction log.
165:             */
166:            public TransactionLog createXaLogService() {
167:                return createTransactionManager().createTransactionLog();
168:            }
169:
170:            /**
171:             * backwards compat
172:             */
173:            @Deprecated
174:            public void setManagementPath(Path managementPath) {
175:                if (_path == null)
176:                    _path = managementPath;
177:            }
178:
179:            /**
180:             * backwards compat
181:             */
182:            @Deprecated
183:            public TransactionManager createTransactionManager()
184:                    throws ConfigException {
185:                if (_transactionManager == null)
186:                    _transactionManager = new TransactionManager(this );
187:
188:                return _transactionManager;
189:            }
190:
191:            @PostConstruct
192:            public void init() {
193:                try {
194:                    if (!_lifecycle.toInit())
195:                        return;
196:
197:                    if (_auth != null) {
198:                        _auth.init();
199:
200:                        WebBeansContainer webBeans = WebBeansContainer.create();
201:
202:                        webBeans.addSingleton(_auth, "resin-admin",
203:                                Standard.class);
204:                    }
205:
206:                    if (_transactionManager != null)
207:                        _transactionManager.start();
208:                } catch (Exception e) {
209:                    throw ConfigException.create(e);
210:                }
211:            }
212:
213:            /**
214:             * Starts the management server
215:             */
216:            public void start(Server server) {
217:                try {
218:                    if (getPath() != null)
219:                        getPath().mkdirs();
220:                } catch (Exception e) {
221:                    throw ConfigException.create(e);
222:                }
223:
224:                if (_deployService != null)
225:                    _deployService.start();
226:            }
227:
228:            public HostConfig getHostConfig() {
229:                if (_hostConfig == null) {
230:                    HostConfig hostConfig = new HostConfig();
231:                    hostConfig.setId(HOST_NAME);
232:                    /*
233:                    if (_path != null) {
234:                    hostConfig.setRootDirectory(new RawString(_path.getFullPath() + "/bogus-admin"));
235:                    }
236:                    else
237:                    hostConfig.setRootDirectory(new RawString("/bogus-admin"));
238:                     */
239:                    hostConfig.setRootDirectory(new RawString("/bogus-admin"));
240:
241:                    hostConfig.setSkipDefaultConfig(true);
242:
243:                    hostConfig.init();
244:
245:                    try {
246:                        if (_server == null)
247:                            _server = _resin.getServer();
248:
249:                        if (_server != null)
250:                            _server.addHost(hostConfig);
251:                    } catch (RuntimeException e) {
252:                        throw e;
253:                    } catch (Exception e) {
254:                        throw ConfigException.create(e);
255:                    }
256:
257:                    _hostConfig = hostConfig;
258:                }
259:
260:                return _hostConfig;
261:            }
262:
263:            protected Cluster getCluster() {
264:                if (_cluster == null)
265:                    _cluster = Cluster.getLocal();
266:
267:                return _cluster;
268:            }
269:
270:            public void destroy() {
271:                TransactionManager transactionManager = _transactionManager;
272:                _transactionManager = null;
273:
274:                DeployManagementService deployService = _deployService;
275:                _deployService = null;
276:
277:                if (transactionManager != null)
278:                    transactionManager.destroy();
279:            }
280:
281:            public static class User {
282:                private String _name;
283:                private String _password;
284:                private boolean _isDisabled;
285:
286:                public void setName(String name) {
287:                    _name = name;
288:                }
289:
290:                public String getName() {
291:                    return _name;
292:                }
293:
294:                public void setPassword(String password) {
295:                    _password = password;
296:                }
297:
298:                public String getPassword() {
299:                    return _password;
300:                }
301:
302:                public void setDisable(boolean isDisabled) {
303:                    _isDisabled = isDisabled;
304:                }
305:
306:                public boolean isDisable() {
307:                    return _isDisabled;
308:                }
309:
310:                PasswordUser getPasswordUser() {
311:                    if (_name == null)
312:                        throw new ConfigException(
313:                                L
314:                                        .l("management <user> requires a 'name' attribute"));
315:
316:                    boolean isAnonymous = false;
317:
318:                    return new PasswordUser(new BasicPrincipal(_name),
319:                            _password.toCharArray(), _isDisabled, isAnonymous,
320:                            new String[] { "resin-admin" });
321:                }
322:            }
323:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.