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


001:        /*
002:         * DPBasedContext.java
003:         *
004:         * Created on November 26, 2001, 12:06 PM
005:         */
006:
007:        package com.sun.portal.desktop.deployment;
008:
009:        import java.util.Vector;
010:        import java.util.Properties;
011:        import java.util.StringTokenizer;
012:        import java.util.logging.Level;
013:        import java.util.logging.Logger;
014:
015:        import java.io.File;
016:        import java.io.FileInputStream;
017:
018:        import com.sun.portal.desktop.dp.DPRoot;
019:        import com.sun.portal.desktop.dp.DPNode;
020:        import com.sun.portal.desktop.dp.DPPropertyHolder;
021:        import com.sun.portal.desktop.dp.DPChannel;
022:        import com.sun.portal.desktop.dp.DPProvider;
023:        import com.sun.portal.desktop.dp.DPString;
024:
025:        import com.sun.portal.util.Platform;
026:
027:        /**
028:         * Common implementation for use in Context based on DP.
029:         */
030:        abstract class DPBasedContext {
031:
032:            public static final String FS = Platform.fs;
033:            public static final String TEMPLATE_BASE_DIR = "templateBaseDir";
034:            public static final String COMMUNITY_TEMPLATE_BASE_DIR = "communityTemplateBaseDir";
035:            public static final String PROVIDER_BASE_DIR = "providerClassBaseDir";
036:            public Logger m_Logger;
037:
038:            public void setLogger(Logger logger) {
039:                m_Logger = logger;
040:            }
041:
042:            protected void setStaticSub(String ss) {
043:
044:                if (ss == null) {
045:                    m_StatSub = null;
046:                    return;
047:                }
048:
049:                StringTokenizer toks = new StringTokenizer(ss, ", ");
050:                Vector v = new Vector();
051:                while (toks.hasMoreTokens()) {
052:                    v.add(toks.nextToken());
053:                }
054:
055:                m_StatSub = (String[]) v.toArray(new String[v.size()]);
056:            }
057:
058:            protected void setPropertyHolder(DPNode root, String objname,
059:                    int types) throws ParFileException {
060:                try {
061:                    if ((types & ExtractOp.TYPE_CHANNEL) != 0) {
062:                        m_Chan = root.getChannel(objname);
063:                        m_Prop = m_Chan;
064:                    } else {
065:                        m_Prop = root.getProvider(objname);
066:                        m_Chan = null;
067:                    }
068:                    m_Types = types;
069:                } catch (Exception ex) {
070:                    throw new ParFileException("errorDPRoot", ex);
071:                }
072:                if (m_Prop == null) {
073:                    Object tok[] = { objname };
074:                    throw new ParFileException("errorNoObject", tok);
075:                }
076:            }
077:
078:            protected String getPBFProperty(String prop, boolean nullok)
079:                    throws ParFileException {
080:                String val = getDesktopProperty(prop, true);
081:                if (val != null) {
082:                    return val;
083:                }
084:
085:                if (m_Prop == null) {
086:                    throw new ParFileException("errorNoPropHolder");
087:                }
088:
089:                try {
090:                    DPString dps = m_Prop.getProperties().getString(prop);
091:                    if (dps != null) {
092:                        val = dps.getStringValue();
093:                    }
094:                } catch (Exception ex) {
095:                    val = null;
096:                }
097:
098:                if (val != null || nullok) {
099:                    return val;
100:                }
101:
102:                Object tok[] = { prop };
103:                throw new ParFileException("errorUndefinedProperty", tok);
104:            }
105:
106:            // Returns Vector so we may implement a search path for finding classes.  The
107:            // first element is understood to be the "preferred" directory which will be used
108:            // for adding new classes.
109:
110:            protected Vector getClassPath() throws ParFileException {
111:
112:                if (m_Classes != null) {
113:                    return m_Classes;
114:                }
115:
116:                // This is consistent with the way the portal server class loader operates.
117:                // It looks first for unpackaged classes in the base directory, then in
118:                // jars contained in that directory.  Then in system classpath entries,
119:                // which should not contain user-installed classes, so we are not interested
120:                // in them.
121:
122:                m_Classes = new Vector();
123:                String bdir = getDesktopProperty(PROVIDER_BASE_DIR, false);
124:                m_Classes.add(bdir);
125:
126:                File f = new File(bdir);
127:                String names[] = f.list();
128:
129:                if (names == null) {
130:                    return m_Classes;
131:                }
132:
133:                for (int i = 0; i < names.length; ++i) {
134:                    if (names[i].endsWith(".jar")) {
135:                        m_Classes.add(bdir + FS + names[i]);
136:                    }
137:                }
138:
139:                return m_Classes;
140:            }
141:
142:            // isJar is intended for use with classpath entries, which are assumed to be legitimate
143:            // jars or directories.  Jars have to exist already.  Otherwise, we wind up assuming
144:            // "directory".
145:
146:            protected boolean isJar(String fn) {
147:                File f = new File(fn);
148:
149:                if (f.isFile()) {
150:                    return true;
151:                }
152:
153:                return false;
154:            }
155:
156:            // getChannel may be null if only a provider has been specified.
157:
158:            protected DPChannel getChannel() {
159:                return m_Chan;
160:            }
161:
162:            protected DPProvider getProvider() throws ParFileException {
163:                if (m_Chan != null) {
164:                    try {
165:                        return m_Chan.getProvider();
166:                    } catch (Exception ex) {
167:                        throw new ParFileException("errorProviderForChannel",
168:                                ex);
169:                    }
170:                }
171:                return (DPProvider) m_Prop;
172:            }
173:
174:            protected int getTypes() {
175:                return m_Types;
176:            }
177:
178:            private String getStaticDirectoryRoot() throws ParFileException {
179:                String dir = System
180:                        .getProperty(ProviderPackageContext.STATICDIR);
181:                if (dir == null) {
182:                    Object tok[] = { ProviderPackageContext.STATICDIR };
183:                    throw new ParFileException("errorSystemProp", tok);
184:                }
185:                return dir;
186:            }
187:
188:            // Index 0 is always defined - used both for import and export.  Import
189:            // allows you to deploy to a list of directories.  For index 0, if no
190:            // subdirectories were specified, we just get the STATICDIR root.
191:
192:            protected String getStaticDirectory(int idx)
193:                    throws ParFileException {
194:                String sroot = getStaticDirectoryRoot();
195:                if (idx == 0 && (m_StatSub == null || m_StatSub.length == 0)) {
196:                    return sroot;
197:                }
198:                return sroot + FS + m_StatSub[idx];
199:            }
200:
201:            protected String getStaticDirectory() throws ParFileException {
202:                return getStaticDirectory(0);
203:            }
204:
205:            protected int getStaticDirectoryCount() {
206:                if (m_StatSub == null || m_StatSub.length == 0) {
207:                    return 1;
208:                }
209:                return m_StatSub.length;
210:            }
211:
212:            protected String getPortalWarDirectory() throws ParFileException {
213:                String dir = System
214:                        .getProperty(ProviderPackageContext.PSWARDIR);
215:                if (dir == null) {
216:                    Object tok[] = { ProviderPackageContext.PSWARDIR };
217:                    throw new ParFileException("errorSystemProp", tok);
218:                }
219:                return dir;
220:            }
221:
222:            protected String getPSDataDirectory() throws ParFileException {
223:                String dir = System
224:                        .getProperty(ProviderPackageContext.PSDATADIR);
225:                if (dir == null) {
226:                    Object tok[] = { ProviderPackageContext.PSDATADIR };
227:                    throw new ParFileException("errorSystemProp", tok);
228:                }
229:                return dir;
230:            }
231:
232:            protected boolean deployDynamic() throws ParFileException {
233:                return true;
234:            }
235:
236:            protected boolean deployStatic() throws ParFileException {
237:                return true;
238:            }
239:
240:            private String getDesktopProperty(String key, boolean nullok)
241:                    throws ParFileException {
242:
243:                String val = null;
244:
245:                if (m_DTProps == null) {
246:                    String sysprop = System
247:                            .getProperty(ProviderPackageContext.DTPROPFILE);
248:                    if (sysprop == null) {
249:                        Object tok[] = { ProviderPackageContext.DTPROPFILE };
250:                        throw new ParFileException("errorSystemProp", tok);
251:                    }
252:                    try {
253:                        m_DTProps = new Properties();
254:                        m_DTProps.load(new FileInputStream(sysprop));
255:                    } catch (Exception ex) {
256:                        //The following code is to workaround the problem in
257:                        //multiportal scenario where a portal was not created 
258:                        //originally on the host where psadmin or console is 
259:                        //executed, in which case the file
260:                        //desktopconfig.properties will not exists on
261:                        //the host. The workaround is to get the ps data
262:                        //directory for the portal the command is exected at,
263:                        //and then construct the value.
264:                        if (m_Logger != null) {
265:                            m_Logger.log(Level.INFO, "DPBaseContext, key:"
266:                                    + key);
267:                        }
268:
269:                        val = getDTPropVal(key);
270:                        if (val != null || nullok) {
271:                            m_DTProps = null;
272:                            return val;
273:                        }
274:
275:                        throw new ParFileException("errorDesktopLoad", ex);
276:                    }
277:                }
278:
279:                val = m_DTProps.getProperty(key);
280:
281:                if (val != null || nullok) {
282:                    return val;
283:                }
284:
285:                Object tok[] = { key, ProviderPackageContext.DTPROPFILE };
286:                throw new ParFileException("Desktop property " + key
287:                        + " not defined in "
288:                        + ProviderPackageContext.DTPROPFILE);
289:
290:            }
291:
292:            private String getDTPropVal(String key) throws ParFileException {
293:                String val = null;
294:
295:                if (key != null) {
296:                    if (key.equals(TEMPLATE_BASE_DIR)) {
297:                        val = getPSDataDirectory() + FS + "desktop";
298:                    } else if (key.equals(COMMUNITY_TEMPLATE_BASE_DIR)) {
299:                        val = getPSDataDirectory() + FS + "communitytemplates";
300:                    } else if (key.equals(PROVIDER_BASE_DIR)) {
301:                        val = getPSDataDirectory() + FS + "desktop" + FS
302:                                + "classes";
303:                    }
304:                    if (m_Logger != null) {
305:                        m_Logger.log(Level.INFO, "DPBaseContext, val:" + val);
306:                    }
307:
308:                }
309:                return val;
310:            }
311:
312:            private DPPropertyHolder m_Prop = null;
313:            private DPChannel m_Chan = null;
314:            private Vector m_Classes = null;
315:            private int m_Types;
316:            private String m_StatSub[] = null;
317:            protected Properties m_DTProps = null;
318:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.