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


001:        /**
002:         * $Id: ListInstancesBean.java,v 1.9 2006/05/15 23:27:46 ru111118 Exp $
003:         * Copyright 2005 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.admin.console.fabric;
014:
015:        import java.util.List;
016:        import java.util.logging.Level;
017:        import java.util.ArrayList;
018:        import java.util.Set;
019:        import java.util.HashSet;
020:        import java.util.Map;
021:        import java.util.Iterator;
022:        import java.io.IOException;
023:        import java.text.MessageFormat;
024:
025:        import javax.management.ObjectName;
026:
027:        import javax.faces.context.FacesContext;
028:        import javax.faces.event.ValueChangeEvent;
029:        import javax.faces.el.VariableResolver;
030:
031:        import com.sun.data.provider.DataProvider;
032:        import com.sun.data.provider.impl.ObjectListDataProvider;
033:        import com.sun.web.ui.component.RadioButton;
034:        import com.sun.web.ui.model.Option;
035:
036:        import com.sun.portal.admin.common.util.AdminClientUtil;
037:        import com.sun.portal.admin.common.InstanceAttributes;
038:
039:        public class ListInstancesBean extends FabricBaseBean {
040:
041:            private DataProvider instances = null;
042:            private List instanceList = null;
043:            private List names = null;
044:            private String portalId = null;
045:            private Option[] instanceNames = null;
046:
047:            /** Creates a new instance of ListPortalsBean*/
048:            public ListInstancesBean() {
049:                portalId = (String) getSessionAttribute(ATTR_SELECTED_PORTAL);
050:                if (portalId == null) {
051:                    FacesContext context = FacesContext.getCurrentInstance();
052:                    VariableResolver vr = context.getApplication()
053:                            .getVariableResolver();
054:                    Object obj = (Object) vr.resolveVariable(context,
055:                            "ListPortalsBean");
056:                    if ((obj != null) && (obj instanceof  ListPortalsBean)) {
057:                        ListPortalsBean listportalsbean = (ListPortalsBean) obj;
058:                        portalId = listportalsbean.getCurrentPortal();
059:                        setSessionAttribute(ATTR_SELECTED_PORTAL, portalId);
060:                    }
061:                }
062:                // Initialize the list of Portal Server instances
063:                buildInstanceList();
064:            }
065:
066:            private void buildInstanceList() {
067:
068:                instanceList = new ArrayList();
069:                names = getInstanceNames();
070:                Iterator iter = names.iterator();
071:                instanceNames = new Option[names.size()];
072:                int count = 0;
073:                while (iter.hasNext()) {
074:                    String name = (String) iter.next();
075:                    Set names = new HashSet();
076:                    names.add(InstanceAttributes.HOST);
077:                    names.add(InstanceAttributes.PORT);
078:                    names.add(InstanceAttributes.WEB_CONTAINER_TYPE);
079:                    Map attrs = (Map) getInstanceAttributes(portalId, name,
080:                            names);
081:                    Set values = (Set) attrs.get(InstanceAttributes.HOST);
082:                    String host = values == null ? "" : (String) (values
083:                            .iterator().next());
084:                    values = (Set) attrs.get(InstanceAttributes.PORT);
085:                    String port = values == null ? "" : (String) (values
086:                            .iterator().next());
087:                    values = (Set) attrs
088:                            .get(InstanceAttributes.WEB_CONTAINER_TYPE);
089:                    String wcType = values == null ? "" : (String) (values
090:                            .iterator().next());
091:                    instanceList
092:                            .add(new InstanceBean(name, host, port, wcType));
093:                    instanceNames[count] = new Option(name);
094:                    if (count == 0) {
095:                        setSessionAttribute(ATTR_SELECTED_INSTANCE, name);
096:                    }
097:                    count++;
098:                }
099:                instances = new ObjectListDataProvider(instanceList);
100:            }
101:
102:            public DataProvider getInstances() {
103:                return instances;
104:            }
105:
106:            public Option[] getInstancesForDropDown() {
107:                return instanceNames;
108:            }
109:
110:            public Object getCurrentInstance() {
111:                return getSessionAttribute(ATTR_SELECTED_INSTANCE);
112:            }
113:
114:            public void setCurrentInstance(Object currentInstance) {
115:                setSessionAttribute(ATTR_SELECTED_INSTANCE, currentInstance);
116:            }
117:
118:            private List getInstanceNames() {
119:                List iNames = new ArrayList();
120:                try {
121:                    Set objNames = getInstanceObjectNames(portalId);
122:                    Iterator iter = objNames.iterator();
123:                    while (iter.hasNext()) {
124:                        iNames
125:                                .add(getAttribute((ObjectName) iter.next(),
126:                                        "ID"));
127:                    }
128:                } catch (IOException ie) {
129:                    log(
130:                            Level.SEVERE,
131:                            "ListInstancesBean.getInstanceNames(): Exception while trying to get the list of portal instances for portalId = "
132:                                    + portalId, ie);
133:                } catch (Exception ex) {
134:                    log(
135:                            Level.SEVERE,
136:                            "ListInstancesBean.getInstanceNames(): Exception while trying to get the list of portal instances for portalId = "
137:                                    + portalId, ex);
138:                }
139:                return iNames;
140:            }
141:
142:            public String newInstance() {
143:                return "newInstance";
144:            }
145:
146:            public String deleteInstance() {
147:
148:                String status = "";
149:                String name = (String) RadioButton.getSelected("rb");
150:                // Set the right params and signature
151:                Object[] iParams = { name };
152:                String[] iSignature = { "java.lang.String" };
153:
154:                try {
155:                    // Get the MBean object for the newly created portal
156:                    ObjectName iObjName = AdminClientUtil
157:                            .getPortalMBeanObjectName(
158:                                    AdminClientUtil.DEFAULT_DOMAIN, portalId);
159:
160:                    log(Level.FINEST, "Invoking deleteInstance for: "
161:                            + portalId);
162:                    // Invoke the delete instance operation
163:                    getMBeanServerConnection().invoke(iObjName,
164:                            "deleteInstance", iParams, iSignature);
165:                    setAlertType("information");
166:                    setAlertSummary(getFabricI18N("message.deleteInstance.success.summary"));
167:                    String ptrn = getFabricI18N("message.deleteInstance.success.details");
168:                    MessageFormat mf = new MessageFormat(ptrn);
169:                    setAlertDetail(mf.format(iParams));
170:                    showAlert();
171:                    buildInstanceList();
172:                } catch (Exception e) {
173:                    log(
174:                            Level.SEVERE,
175:                            "ListInstancesBean.deleteInstance(): Delete Instance operation failed",
176:                            e);
177:                    setAlertType("error");
178:                    setAlertSummary(getFabricI18N("message.deleteInstance.failed.summary"));
179:                    String ptrn = getFabricI18N("message.deleteInstance.failed.details");
180:                    MessageFormat mf = new MessageFormat(ptrn);
181:                    setAlertDetail(mf.format(iParams));
182:                    showAlert();
183:                }
184:                return status;
185:            }
186:
187:            public String gotoInstanceInfo() {
188:                return "instanceInfo";
189:            }
190:
191:            public void processInstanceChange(ValueChangeEvent evt) {
192:                Object currentInstance = evt.getNewValue();
193:                log(Level.FINEST,
194:                        "Processing Value Change for Instance: New Instance="
195:                                + currentInstance);
196:                setCurrentInstance(currentInstance);
197:            }
198:
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.