Source Code Cross Referenced for SRAProxiesBean.java in  » Portal » Open-Portal » com » sun » portal » admin » console » sra » monitoring » 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 » Portal » Open Portal » com.sun.portal.admin.console.sra.monitoring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.admin.console.sra.monitoring;
002:
003:        import com.sun.data.provider.impl.ObjectListDataProvider;
004:        import com.sun.data.provider.DataProvider;
005:        import com.sun.portal.admin.console.sra.SraBaseBean;
006:        import com.sun.portal.admin.console.sra.gateway.GatewayBean;
007:        import com.sun.portal.admin.console.sra.gateway.TwoParamBean;
008:        import com.sun.portal.admin.console.sra.utils.Util;
009:
010:        import com.sun.portal.admin.common.util.AdminClientUtil;
011:
012:        import java.util.*;
013:        import java.util.logging.Level;
014:
015:        /**
016:         * author: Noble Paul
017:         * Date: Jun 1, 2005, 4:04:25 PM
018:         */
019:        public class SRAProxiesBean extends SraBaseBean {
020:            public static final int UNINITIALIZED = -1;
021:            static final int STARTED = 1;
022:            static final int STOPPED = 2;
023:            private List gatewayInstances, rwpInstances, nlpInstances;
024:
025:            private List profiles = new ArrayList();
026:
027:            public SRAProxiesBean() {
028:                super (GATEWAY_SVC, new String[0]);
029:                initData();
030:            }
031:
032:            public void initData() {
033:                List p = getSraProfiles();
034:                profiles = new ArrayList();
035:                for (int i = 0; i < p.size(); i++) {
036:                    Profile profile = new Profile((String) p.get(i));
037:                    profiles.add(profile);
038:                }
039:            }
040:
041:            private void fetchInstances() {
042:                if (gatewayInstances == null)
043:                    gatewayInstances = getSraInstances(SRA_INSTANCE_TYPE_GATEWAY);
044:                if (rwpInstances == null)
045:                    rwpInstances = getSraInstances(SRA_INSTANCE_TYPE_REWRITER_PROXY);
046:                if (nlpInstances == null)
047:                    nlpInstances = getSraInstances(SRA_INSTANCE_TYPE_NETLET_PROXY);
048:            }
049:
050:            private void populateProfile(Profile profile, int type, List insts) {
051:                for (int j = 0; j < insts.size(); j++) {
052:                    String s = (String) insts.get(j);
053:                    if (s.startsWith(profile.name + ":")) {
054:                        if (s.length() < profile.name.length() + 2)
055:                            continue;
056:
057:                        String hostAndIP = s.substring(s.indexOf(':') + 1);//.replace('|',' ');
058:                        String host = hostAndIP.substring(0, hostAndIP
059:                                .indexOf("|"));
060:                        String ip = hostAndIP
061:                                .substring(hostAndIP.indexOf("|") + 1);
062:                        profile.addInstance(new SRAInstance(type, host, ip,
063:                                profile));
064:                    }
065:                }
066:            }
067:
068:            public List getProfiles() {
069:                return profiles;
070:            }
071:
072:            public class SRAInstance {
073:                public static final String PORT_PROPERTY = "com.sun.portal.monitoring.security.ssl.SslContext.port";
074:                int status = UNINITIALIZED;
075:                int monitoringStatus = UNINITIALIZED;
076:                int type;
077:                String host;
078:                String ip;
079:                private boolean instanceStarted = false;
080:                private Profile profile;
081:                private boolean selected;
082:
083:                public SRAInstance(int type, String host, String ip,
084:                        Profile profile) {
085:                    this .host = host;
086:                    this .ip = ip;
087:                    this .type = type;
088:                    this .profile = profile;
089:                }
090:
091:                public String getHost() {
092:                    return host + " " + ip;
093:                }
094:
095:                public String getHostName() {
096:                    return host;
097:                }
098:
099:                public String getIp() {
100:                    return ip;
101:                }
102:
103:                public boolean isStarted() {
104:                    if (status == UNINITIALIZED) {
105:                        if (type == SRA_INSTANCE_TYPE_NETLET_PROXY
106:                                || type == SRA_INSTANCE_TYPE_REWRITER_PROXY) {
107:                            try {
108:                                String methName = (type == SRA_INSTANCE_TYPE_NETLET_PROXY) ? "GetNetletProxyPort"
109:                                        : "GetRewriterProxyPort";
110:                                if (isSraInstanceStarted(
111:                                        type,
112:                                        profile.getName(),
113:                                        host,
114:                                        getSraProxyPort(type,
115:                                                profile.getName(), host))
116:                                        .booleanValue()) {
117:                                    status = STARTED;
118:                                    return true;
119:                                } else {
120:                                    status = STOPPED;
121:                                    return false;
122:                                }
123:                            } catch (Exception e) {
124:                                return false;
125:                            }
126:                        }
127:
128:                        if (profile.getHttpsPort() > 0) {
129:                            if (isSraInstanceStarted(type, profile.getName(),
130:                                    host, profile.getHttpsPort())
131:                                    .booleanValue()) {
132:                                status = STARTED;
133:                                return true;
134:                            }
135:                        }
136:                        if (profile.getHttpPort() > 0) {
137:                            if (isSraInstanceStarted(type, profile.getName(),
138:                                    getHostName(), profile.getHttpPort())
139:                                    .booleanValue()) {
140:                                status = STARTED;
141:                                return true;
142:                            }
143:                        }
144:
145:                        status = STOPPED;
146:                    }
147:                    if (status == STARTED) {
148:                        return true;
149:                    }
150:                    return false;
151:                }
152:
153:                public void setInstanceStarted(boolean instanceStarted) {
154:                    this .instanceStarted = instanceStarted;
155:                }
156:
157:                public String getType() {
158:                    switch (type) {
159:                    case SRA_INSTANCE_TYPE_GATEWAY:
160:                        return Util.evaluateCachedValueBinding(
161:                                "#{monitoring['proxy.gw.name']}").toString();
162:                    case SRA_INSTANCE_TYPE_NETLET_PROXY:
163:                        return Util.evaluateCachedValueBinding(
164:                                "#{monitoring['proxy.nlp.name']}").toString();
165:                    case SRA_INSTANCE_TYPE_REWRITER_PROXY:
166:                        return Util.evaluateCachedValueBinding(
167:                                "#{monitoring['proxy.rwp.name']}").toString();
168:                    default:
169:                        return "NOT KNOWN";
170:                    }
171:                }
172:
173:                public String getTypeShort() {
174:                    return Util.getProxyTypeName(type);
175:                }
176:
177:                public void setType(int type) {
178:                    this .type = type;
179:                }
180:
181:                public String getStatus() {
182:                    return isStarted() ? Util.evaluateCachedValueBinding(
183:                            "#{monitoring['instance.running.label']}")
184:                            .toString() : Util.evaluateCachedValueBinding(
185:                            "#{monitoring['instance.stopped.label']}")
186:                            .toString();
187:                }
188:
189:                public Profile getProfile() {
190:                    return profile;
191:                }
192:
193:                public int getMonitoringStatus() {
194:                    if (monitoringStatus == UNINITIALIZED) {
195:                        monitoringStatus = isMonitoringEnabled() ? STARTED
196:                                : STOPPED;
197:                    }
198:                    return monitoringStatus;
199:                }
200:
201:                private boolean isMonitoringEnabled() {
202:                    Object port = invokeRemoteMBean(host,
203:                            AdminClientUtil.SRA_MONITORING_MBEAN,
204:                            "getMonitoringProperty", new Object[] {
205:                                    Util.getProxyTypeName(type),
206:                                    profile.getName(), PORT_PROPERTY },
207:                            new String[] { STRING, STRING, STRING });
208:
209:                    try {
210:                        port = Integer.valueOf((String) port);
211:                    } catch (NumberFormatException e) {
212:                        return false;
213:                    }
214:                    return isSraInstanceStarted(type, profile.getName(),
215:                            this .host, ((Integer) port).intValue())
216:                            .booleanValue();
217:                }
218:
219:                public boolean getSelected() {
220:                    return selected;
221:                }
222:
223:                public void setSelected(boolean selected) {
224:                    this .selected = selected;
225:                }
226:            }
227:
228:            public class Profile {
229:                String name;
230:                boolean selected;
231:                public static final int DISABLED = -2;
232:                int httpPort = UNINITIALIZED;
233:                int httpsPort = UNINITIALIZED;
234:                private List instances = null;
235:                private ObjectListDataProvider instancesData;
236:
237:                public Profile(String name) {
238:                    this .name = name;
239:                }
240:
241:                public void addInstance(SRAInstance s) {
242:                    instances.add(s);
243:                }
244:
245:                public String getName() {
246:                    return name;
247:                }
248:
249:                public void setName(String name) {
250:                    this .name = name;
251:                }
252:
253:                public ObjectListDataProvider getInstances() {
254:                    if (instancesData == null) {
255:                        instancesData = new ObjectListDataProvider(
256:                                getInstancesList());
257:                    }
258:
259:                    return instancesData;
260:                }
261:
262:                public List getInstancesList() {
263:                    if (instances == null) {
264:                        instances = new ArrayList();
265:                        fetchInstances();
266:                        populateProfile(this , SRA_INSTANCE_TYPE_GATEWAY,
267:                                gatewayInstances);
268:                        populateProfile(this , SRA_INSTANCE_TYPE_NETLET_PROXY,
269:                                nlpInstances);
270:                        populateProfile(this , SRA_INSTANCE_TYPE_REWRITER_PROXY,
271:                                rwpInstances);
272:                    }
273:                    return instances;
274:                }
275:
276:                public boolean getSelected() {
277:                    return selected;
278:                }
279:
280:                public void setSelected(boolean selected) {
281:                    this .selected = selected;
282:                }
283:
284:                public int getHttpPort() {
285:                    if (httpPort == UNINITIALIZED) {
286:                        try {
287:                            _sraProfileName = name;
288:                            getDataFromStore(GatewayBean.ENABLE_HTTP);
289:                            if (!getBooleanValue(GatewayBean.ENABLE_HTTP)) {
290:                                httpPort = DISABLED;
291:                                return httpPort;
292:                            }
293:                            getDataFromStore(GatewayBean.HTTP_PORT);
294:                            httpPort = getIntValue(GatewayBean.HTTP_PORT);
295:                        } catch (Exception e) {
296:                            httpPort = DISABLED;
297:                            log(
298:                                    Level.SEVERE,
299:                                    "SRAProxiesBean.getHttpPort() : Exception ",
300:                                    e);
301:                        }
302:
303:                    }
304:                    return httpPort;
305:                }
306:
307:                public int getHttpsPort() {
308:                    if (httpsPort == UNINITIALIZED) {
309:                        try {
310:                            _sraProfileName = name;
311:                            getDataFromStore(GatewayBean.ENABLE_HTTPS);
312:                            if (!getBooleanValue(GatewayBean.ENABLE_HTTPS)) {
313:                                httpsPort = DISABLED;
314:                                return httpsPort;
315:                            }
316:                            getDataFromStore(GatewayBean.HTTPS_PORT);
317:                            httpsPort = getIntValue(GatewayBean.HTTPS_PORT);
318:                        } catch (Exception e) {
319:                            httpsPort = DISABLED;
320:                            log(
321:                                    Level.SEVERE,
322:                                    "SRAProxiesBean.getHttpsPort() : Exception ",
323:                                    e);
324:                        }
325:                    }
326:                    return httpsPort;
327:                }
328:            }
329:
330:            public void stopInstance() {
331:                SRAInstance sraInstance = getSelectedInstance();
332:                if (sraInstance != null) {
333:                    String methodName = null;
334:                    switch (sraInstance.type) {
335:                    case SRA_INSTANCE_TYPE_GATEWAY:
336:                        methodName = "StopGateway";
337:                        break;
338:                    case SRA_INSTANCE_TYPE_NETLET_PROXY:
339:                        methodName = "StopNetletd";
340:                        break;
341:                    case SRA_INSTANCE_TYPE_REWRITER_PROXY:
342:                        methodName = "StopRWProxy";
343:                        break;
344:                    }
345:                    invokeRemoteMBean(sraInstance.host,
346:                            AdminClientUtil.SRA_MBEAN, methodName,
347:                            new Object[] { sraInstance.profile.name },
348:                            new String[] { STRING });
349:                }
350:            }
351:
352:            public String monitorInstance() {
353:                SRAInstance sraInstance = getSelectedInstance();
354:                if (sraInstance != null) {
355:                    Util.setRequestAttribute("proxy", sraInstance
356:                            .getTypeShort());
357:                    Util.setRequestAttribute("host", sraInstance.getHostName());
358:                    Util.setRequestAttribute("profile", sraInstance
359:                            .getProfile().getName());
360:                }
361:                return "monitor";
362:            }
363:
364:            private SRAInstance getSelectedInstance() {
365:
366:                String inst = (String) Util.getRequestParameter("sel_inst");
367:                StringTokenizer stringTokenizer = new StringTokenizer(inst,
368:                        ":", false);
369:                String profName = stringTokenizer.nextToken();
370:                String type = stringTokenizer.nextToken();
371:                String host = stringTokenizer.nextToken();
372:
373:                for (int i = 0; i < profiles.size(); i++) {
374:                    Profile profile = (Profile) profiles.get(i);
375:                    //            profile.getInstances().commitChanges();
376:                    List insts = profile.getInstances().getList();
377:                    for (int j = 0; j < insts.size(); j++) {
378:                        SRAInstance sraInstance = (SRAInstance) insts.get(j);
379:                        if (sraInstance.getProfile().getName().equals(profName)
380:                                && sraInstance.getTypeShort().equals(type)
381:                                && sraInstance.getHostName().equals(host)) {
382:                            return sraInstance;
383:                        }
384:                    }
385:                }
386:                return null;
387:
388:            }
389:
390:            public void startInstance() {
391:                SRAInstance sraInstance = getSelectedInstance();
392:                if (sraInstance != null) {
393:                    String methodName = null;
394:                    switch (sraInstance.type) {
395:                    case SRA_INSTANCE_TYPE_GATEWAY:
396:                        methodName = "StartGateway";
397:                        break;
398:                    case SRA_INSTANCE_TYPE_NETLET_PROXY:
399:                        methodName = "StartNetletd";
400:                        break;
401:                    case SRA_INSTANCE_TYPE_REWRITER_PROXY:
402:                        methodName = "StartRWProxy";
403:                        break;
404:                    }
405:                    invokeRemoteMBean(sraInstance.host,
406:                            AdminClientUtil.SRA_MBEAN, methodName,
407:                            new Object[] { sraInstance.profile.name },
408:                            new String[] { STRING });
409:                    //startSraInstance(sraInstance.type,sraInstance.profile.name);
410:                }
411:            }
412:
413:            public DataProvider getInstanceProperties() {
414:                if (instanceData != null)
415:                    return instanceData;
416:
417:                Map properties = getResourceStringMap("instancetemplate");
418:                List result = new ArrayList();
419:
420:                for (Iterator iterator = properties.entrySet().iterator(); iterator
421:                        .hasNext();) {
422:                    Map.Entry entry = (Map.Entry) iterator.next();
423:                    String name = (String) entry.getKey();
424:                    String value = (String) entry.getValue();
425:                    result.add(new TwoParamBean(name, value));
426:                }
427:                return instanceData = new ObjectListDataProvider(result);
428:            }
429:
430:            DataProvider instanceData = null;
431:
432:        }
w__w__w_.___j__a_v___a2___s___.c__om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.