Source Code Cross Referenced for CorePlugin.java in  » GIS » udig-1.1 » net » refractions » udig » core » internal » 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 » GIS » udig 1.1 » net.refractions.udig.core.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.refractions.udig.core.internal;
002:
003:        import java.io.File;
004:        import java.io.IOException;
005:        import java.net.MalformedURLException;
006:        import java.net.URL;
007:        import java.net.URLConnection;
008:        import java.net.URLStreamHandler;
009:        import java.util.ArrayList;
010:        import java.util.List;
011:
012:        import org.eclipse.core.runtime.IStatus;
013:        import org.eclipse.core.runtime.Platform;
014:        import org.eclipse.core.runtime.Plugin;
015:        import org.eclipse.core.runtime.Status;
016:        import org.osgi.framework.BundleContext;
017:        import org.picocontainer.MutablePicoContainer;
018:        import org.picocontainer.defaults.DefaultPicoContainer;
019:
020:        /**
021:         * PlugIn for net.refractions.udig.core, used by utility classes to access workbench log.
022:         * 
023:         * @author jones
024:         * @since 0.3
025:         */
026:        public class CorePlugin extends Plugin {
027:
028:            /** Plugin <code>ID</code> field */
029:            public static final String ID = "net.refractions.udig.core"; //$NON-NLS-1$
030:            private static CorePlugin plugin;
031:
032:            /**
033:             * A url stream handler that delegates to the default one but if it doesn't work then it returns null as the stream.
034:             */
035:            public final static URLStreamHandler RELAXED_HANDLER = new URLStreamHandler() {
036:
037:                @Override
038:                protected URLConnection openConnection(URL u)
039:                        throws IOException {
040:                    try {
041:                        URL url = new URL(u.toString());
042:                        return url.openConnection();
043:                    } catch (MalformedURLException e) {
044:                        return null;
045:                    }
046:                }
047:            };
048:
049:            /**
050:             * creates a plugin instance
051:             */
052:            public CorePlugin() {
053:                super ();
054:                plugin = this ;
055:            }
056:
057:            /**
058:             * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
059:             */
060:            public void start(BundleContext context) throws Exception {
061:                super .start(context);
062:
063:            }
064:
065:            /**
066:             * Returns the system created plugin object
067:             * 
068:             * @return the plugin object
069:             */
070:            public static CorePlugin getDefault() {
071:                return plugin;
072:            }
073:
074:            private static volatile MutablePicoContainer blackboard = null;
075:
076:            /**
077:             * This is intended to return the top level Pico Container to use for blackBoarding.
078:             * <p>
079:             * For most applications, a sub container is required. I recommend the following code be
080:             * inserted into your main plugin class. <code>
081:             * private static MutablePicoContainer myContainer = null;
082:             * 
083:             * /**
084:             *  * Gets the container for my plugin.
085:             *  * 
086:             *  * Make it 'public' if you want to share ... protected otherwise.
087:             *  * /
088:             * public static MutablePicoContainer getMyContainer(){
089:             *   if(myContainer == null){
090:             *     // XXXPlugin is the name of the Plugin class
091:             *     synchronized(XXXPlugin.class){
092:             *       // check so see that you were not queued for double creation
093:             *       if(myContainer == null){
094:             *         // This line does it ... careful to only call it once!
095:             *         myContainer = CorePlugin.getBlackBoard().makeChildContainer();
096:             *       }
097:             *     }
098:             *   }
099:             *   return myContainer;
100:             * }
101:             * </code>
102:             * </p>
103:             * <p>
104:             * NOTE:<br>
105:             * Please check to ensure the child you want is not already created (important for two plugins
106:             * sharing one container).
107:             * </p>
108:             * 
109:             * @return
110:             */
111:            public static MutablePicoContainer getBlackBoard() {
112:                if (blackboard == null) {
113:                    synchronized (CorePlugin.class) {
114:                        if (blackboard == null) {
115:                            blackboard = new DefaultPicoContainer();
116:                        }
117:                    }
118:                }
119:                return blackboard;
120:            }
121:
122:            /**
123:             * Takes a string, and splits it on '\n' and calls stringsToURLs(String[])
124:             */
125:            public static List<URL> stringsToURLs(String string) {
126:                String[] strings = string.split("\n"); //$NON-NLS-1$
127:
128:                return stringsToURLs(strings);
129:            }
130:
131:            /**
132:             * Converts each element of an array from a String to a URL. If the String is not a valid URL,
133:             * it attempts to load it as a File and then convert it. If that fails, it ignores it. It will
134:             * not insert a null into the returning List, so the size of the List may be smaller than the
135:             * size of <code>strings</code>
136:             * 
137:             * @param strings an array of strings, each to be converted to a URL
138:             * @return a List of URLs, in the same order as the array
139:             */
140:            public static List<URL> stringsToURLs(String[] strings) {
141:                List<URL> urls = new ArrayList<URL>();
142:
143:                for (String string : strings) {
144:                    try {
145:                        urls.add(new URL(string));
146:                    } catch (MalformedURLException e) {
147:                        // not a URL, maybe it is a file
148:                        try {
149:                            urls.add(new File(string).toURL());
150:                        } catch (MalformedURLException e1) {
151:                            // Not a URL, not a File. nothing to do now.
152:                        }
153:                    }
154:                }
155:                return urls;
156:            }
157:
158:            /**
159:             * Writes an info log in the plugin's log.
160:             * <p>
161:             * This should be used for user level messages.
162:             * </p>
163:             */
164:            public static void log(String message2, Throwable e) {
165:                String message = message2;
166:                if (message == null)
167:                    message = ""; //$NON-NLS-1$
168:                getDefault().getLog().log(
169:                        new Status(IStatus.INFO, ID, 0, message, e));
170:            }
171:
172:            /**
173:             * Messages that only engage if getDefault().isDebugging()
174:             * <p>
175:             * It is much prefered to do this:
176:             * 
177:             * <pre><code>
178:             * private static final String RENDERING = &quot;net.refractions.udig.project/render/trace&quot;;
179:             * if (ProjectUIPlugin.getDefault().isDebugging() &amp;&amp; &quot;true&quot;.equalsIgnoreCase(RENDERING)) {
180:             *     System.out.println(&quot;your message here&quot;);
181:             * }
182:             * 
183:             */
184:            public static void trace(String message, Throwable e) {
185:                if (getDefault().isDebugging()) {
186:                    if (message != null)
187:                        System.out.println(message);
188:                    if (e != null)
189:                        e.printStackTrace();
190:                }
191:            }
192:
193:            /**
194:             * Performs the Platform.getDebugOption true check on the provided trace
195:             * <p>
196:             * Note: ProjectUIPlugin.getDefault().isDebugging() must also be on.
197:             * <ul>
198:             * <li>Trace.RENDER - trace rendering progress
199:             * </ul>
200:             * </p>
201:             * 
202:             * @param trace currently only RENDER is defined
203:             */
204:            public static boolean isDebugging(final String trace) {
205:                return getDefault().isDebugging()
206:                        && "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$    
207:            }
208:
209:            public static boolean isDeveloping() {
210:                return System.getProperty("UDIG_DEVELOPING") != null; //$NON-NLS-1$
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.