Skip to content

Commit 60c7049

Browse files
committed
Feature : LoggingSupport
for logging & tracing the same way for all modules Signed-off-by: Frank Gasdorf <[email protected]>
1 parent e0533da commit 60c7049

File tree

345 files changed

+9689
-10803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

345 files changed

+9689
-10803
lines changed
974 Bytes
Binary file not shown.

plugins/org.locationtech.udig.catalog.arcgrid/src/org/locationtech/udig/arcgrid/ArcGridPlugin.java

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,48 @@
1616
import org.osgi.framework.BundleContext;
1717

1818
public class ArcGridPlugin extends AbstractUIPlugin {
19-
private static ArcGridPlugin plugin;
20-
private ResourceBundle resourceBundle;
21-
22-
public ArcGridPlugin() {
23-
super();
24-
plugin = this;
25-
}
26-
27-
public void start(BundleContext context) throws Exception {
28-
super.start(context);
29-
}
30-
31-
public void stop(BundleContext context) throws Exception {
32-
plugin = null;
33-
this.resourceBundle = null;
34-
super.stop(context);
35-
}
36-
37-
public static ArcGridPlugin getDefault() {
38-
return plugin;
39-
}
40-
41-
public static String getResourceString(String key) {
42-
ResourceBundle bundle = ArcGridPlugin.getDefault().getResourceBundle();
43-
try {
44-
return (bundle != null) ? bundle.getString(key) : key;
45-
} catch (MissingResourceException e) {
46-
return key;
47-
}
48-
}
49-
50-
public ResourceBundle getResourceBundle() {
51-
try {
52-
if (this.resourceBundle == null)
53-
this.resourceBundle = ResourceBundle.getBundle(
19+
private static ArcGridPlugin plugin;
20+
21+
private ResourceBundle resourceBundle;
22+
23+
public ArcGridPlugin() {
24+
super();
25+
plugin = this;
26+
}
27+
28+
@Override
29+
public void start(BundleContext context) throws Exception {
30+
super.start(context);
31+
}
32+
33+
@Override
34+
public void stop(BundleContext context) throws Exception {
35+
plugin = null;
36+
this.resourceBundle = null;
37+
super.stop(context);
38+
}
39+
40+
public static ArcGridPlugin getDefault() {
41+
return plugin;
42+
}
43+
44+
public static String getResourceString(String key) {
45+
ResourceBundle bundle = ArcGridPlugin.getDefault().getResourceBundle();
46+
try {
47+
return (bundle != null) ? bundle.getString(key) : key;
48+
} catch (MissingResourceException e) {
49+
return key;
50+
}
51+
}
52+
53+
public ResourceBundle getResourceBundle() {
54+
try {
55+
if (this.resourceBundle == null)
56+
this.resourceBundle = ResourceBundle.getBundle(
5457
"org.locationtech.udig.arcgrid.internal.arcgrid.ArcGridPluginResources"); //$NON-NLS-1$
55-
} catch (MissingResourceException x) {
56-
this.resourceBundle = null;
57-
}
58-
return this.resourceBundle;
59-
}
58+
} catch (MissingResourceException x) {
59+
this.resourceBundle = null;
60+
}
61+
return this.resourceBundle;
62+
}
6063
}

plugins/org.locationtech.udig.catalog.arcsde/src/org/locationtech/udig/catalog/internal/arcsde/ArcServiceImpl.java

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,34 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import org.eclipse.core.runtime.IProgressMonitor;
23+
import org.eclipse.core.runtime.NullProgressMonitor;
24+
import org.eclipse.ui.plugin.AbstractUIPlugin;
25+
import org.geotools.arcsde.data.ArcSDEDataStoreConfig;
26+
import org.geotools.arcsde.session.ArcSDEConnectionConfig;
27+
import org.geotools.data.DataStore;
2228
import org.locationtech.udig.catalog.CatalogPlugin;
2329
import org.locationtech.udig.catalog.IGeoResource;
2430
import org.locationtech.udig.catalog.IResolveChangeEvent;
2531
import org.locationtech.udig.catalog.IResolveDelta;
2632
import org.locationtech.udig.catalog.IService;
2733
import org.locationtech.udig.catalog.IServiceInfo;
28-
import org.locationtech.udig.catalog.IResolve.Status;
2934
import org.locationtech.udig.catalog.internal.CatalogImpl;
3035
import org.locationtech.udig.catalog.internal.ResolveChangeEvent;
3136
import org.locationtech.udig.catalog.internal.ResolveDelta;
32-
33-
import org.eclipse.core.runtime.IProgressMonitor;
34-
import org.eclipse.core.runtime.NullProgressMonitor;
35-
import org.eclipse.ui.plugin.AbstractUIPlugin;
36-
import org.geotools.arcsde.data.ArcSDEDataStoreConfig;
37-
import org.geotools.arcsde.session.ArcSDEConnectionConfig;
38-
import org.geotools.data.DataStore;
37+
import org.locationtech.udig.core.logging.LoggingSupport;
3938

4039
/**
4140
* Connect to ArcSDE.
42-
*
41+
*
4342
* @author David Zwiers, Refractions Research
4443
* @since 0.6
4544
*/
4645
public class ArcServiceImpl extends IService {
47-
46+
4847
/** Identifier used in Catalog */
4948
private final URL url;
50-
49+
5150
/** Current connection error - if any */
5251
private Throwable msg;
5352

@@ -62,15 +61,15 @@ public class ArcServiceImpl extends IService {
6261

6362
/** List of child members, provided by {@link #vectorService} and {@link #rasterService}. */
6463
private volatile List<IGeoResource> members;
65-
64+
6665
/**
6766
* ArcSDE DataStore details used for connection.
6867
*/
6968
private final ArcSDEDataStoreConfig dataStoreConfig;
7069

7170
/**
7271
* Construct <code>PostGISServiceImpl</code>.
73-
*
72+
*
7473
* @param url
7574
* @param params
7675
*/
@@ -84,6 +83,7 @@ public ArcServiceImpl( URL url, Map<String, Serializable> params ) {
8483
/**
8584
* @see IService#resolve(Class, IProgressMonitor)
8685
*/
86+
@Override
8787
public <T> T resolve( final Class<T> adaptee, IProgressMonitor monitor ) throws IOException {
8888
if (monitor == null) {
8989
monitor = new NullProgressMonitor();
@@ -111,6 +111,7 @@ public <T> T resolve( final Class<T> adaptee, IProgressMonitor monitor ) throws
111111
/**
112112
* @see org.locationtech.udig.catalog.IResolve#canResolve(Class)
113113
*/
114+
@Override
114115
public <T> boolean canResolve( Class<T> adaptee ) {
115116
if (adaptee == null) {
116117
return false;
@@ -123,7 +124,7 @@ public <T> boolean canResolve( Class<T> adaptee ) {
123124
// }
124125
return super.canResolve(adaptee);
125126
}
126-
127+
127128
/**
128129
* @see IService#resources(IProgressMonitor)
129130
*/
@@ -132,7 +133,7 @@ public List<IGeoResource> resources( final IProgressMonitor monitor ) throws IOE
132133
if (members == null) {
133134
synchronized (this) {
134135
if (members == null) {
135-
members = new ArrayList<IGeoResource>();
136+
members = new ArrayList<>();
136137
if (vectorService != null) {
137138
members.addAll(vectorService.resources(monitor));
138139
}
@@ -177,13 +178,15 @@ protected IServiceInfo createInfo( IProgressMonitor monitor ) throws IOException
177178
/**
178179
* @see IService#getConnectionParams()
179180
*/
181+
@Override
180182
public Map<String, Serializable> getConnectionParams() {
181183
return dataStoreConfig == null ? null : dataStoreConfig.toMap();
182184
}
183185

184186
/**
185187
* @see IService#getStatus()
186188
*/
189+
@Override
187190
public Status getStatus() {
188191
if( vectorService == null ){
189192
return super.getStatus();
@@ -194,13 +197,15 @@ public Status getStatus() {
194197
/**
195198
* @see IService#getMessage()
196199
*/
200+
@Override
197201
public Throwable getMessage() {
198202
return msg;
199203
}
200204

201205
/**
202206
* @see IService#getIdentifier()
203207
*/
208+
@Override
204209
public URL getIdentifier() {
205210
return url;
206211
}
@@ -218,24 +223,26 @@ public ArcSDEVectorService getVectorService() {
218223
}
219224

220225
private static class IServiceArcSDEInfo extends IServiceInfo {
221-
226+
222227
private final URL identifier;
223-
228+
224229
IServiceArcSDEInfo( final URL identifier, final ArcSDEConnectionConfig connectionConfig ) {
225230
this.identifier = identifier;
226231
try {
227232
schema = new URI("arcsde://geotools/gml"); //$NON-NLS-1$
228233
} catch (URISyntaxException e) {
229-
ArcsdePlugin.log(null, e);
234+
LoggingSupport.log(ArcsdePlugin.getDefault(), e);
230235
}
231236
icon = AbstractUIPlugin.imageDescriptorFromPlugin(ArcsdePlugin.ID,
232237
"icons/obj16/arcsde_obj.gif"); //$NON-NLS-1$
233238
}
234-
239+
240+
@Override
235241
public String getDescription() {
236242
return identifier.toString();
237243
}
238-
244+
245+
@Override
239246
public URI getSource() {
240247
try {
241248
return identifier.toURI();
@@ -244,10 +251,11 @@ public URI getSource() {
244251
throw (RuntimeException) new RuntimeException().initCause(e);
245252
}
246253
}
247-
254+
255+
@Override
248256
public String getTitle() {
249257
return "ARCSDE " + identifier.getHost(); //$NON-NLS-1$
250258
}
251-
259+
252260
}
253261
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*
2-
* uDig - User Friendly Desktop Internet GIS client
3-
* http://udig.refractions.net
4-
* (C) 2012, Refractions Research Inc.
1+
/**
2+
* uDig - User Friendly Desktop Internet GIS client
3+
* http://udig.refractions.net
4+
* (C) 2012, Refractions Research Inc.
55
*
66
* All rights reserved. This program and the accompanying materials
77
* are made available under the terms of the Eclipse Public License v1.0
@@ -13,9 +13,6 @@
1313
import java.util.MissingResourceException;
1414
import java.util.ResourceBundle;
1515

16-
import org.eclipse.core.runtime.IStatus;
17-
import org.eclipse.core.runtime.Platform;
18-
import org.eclipse.core.runtime.Status;
1916
import org.eclipse.ui.plugin.AbstractUIPlugin;
2017
import org.osgi.framework.BundleContext;
2118

@@ -46,13 +43,15 @@ public ArcsdePlugin() {
4643
/**
4744
* This method is called upon plug-in activation
4845
*/
46+
@Override
4947
public void start( BundleContext context ) throws Exception {
5048
super.start(context);
5149
}
5250

5351
/**
5452
* This method is called when the plug-in is stopped
5553
*/
54+
@Override
5655
public void stop( BundleContext context ) throws Exception {
5756
plugin = null;
5857
resourceBundle = null;
@@ -61,7 +60,7 @@ public void stop( BundleContext context ) throws Exception {
6160

6261
/**
6362
* Returns the shared instance.
64-
*
63+
*
6564
* @return x
6665
*/
6766
public static ArcsdePlugin getDefault() {
@@ -70,7 +69,7 @@ public static ArcsdePlugin getDefault() {
7069

7170
/**
7271
* Returns the string from the plugin's resource bundle, or 'key' if not found.
73-
*
72+
*
7473
* @param key
7574
* @return x
7675
*/
@@ -85,7 +84,7 @@ public static String getResourceString( String key ) {
8584

8685
/**
8786
* Returns the plugin's resource bundle,
88-
*
87+
*
8988
* @return x
9089
*/
9190
public ResourceBundle getResourceBundle() {
@@ -98,52 +97,4 @@ public ResourceBundle getResourceBundle() {
9897
}
9998
return resourceBundle;
10099
}
101-
102-
/**
103-
* Logs the Throwable in the plugin's log.
104-
* <p>
105-
* This will be a user visable ERROR iff:
106-
* <ul>
107-
* <li>t is an Exception we are assuming it is human readable or if a message is provided
108-
*/
109-
public static void log( String message, Throwable t ) {
110-
int status = t instanceof Exception || message != null ? IStatus.ERROR : IStatus.WARNING;
111-
getDefault().getLog().log(new Status(status, ID, IStatus.OK, message, t));
112-
}
113-
114-
/**
115-
* Messages that only engage if getDefault().isDebugging()
116-
* <p>
117-
* It is much prefered to do this:
118-
*
119-
* <pre><code>
120-
* private static final String RENDERING = &quot;org.locationtech.udig.project/render/trace&quot;;
121-
* if (ProjectUIPlugin.getDefault().isDebugging() &amp;&amp; &quot;true&quot;.equalsIgnoreCase(RENDERING)) {
122-
* System.out.println(&quot;your message here&quot;);
123-
* }
124-
*/
125-
public static void trace( String message, Throwable e ) {
126-
if (getDefault().isDebugging()) {
127-
if (message != null)
128-
System.out.println(message);
129-
if (e != null)
130-
e.printStackTrace();
131-
}
132-
}
133-
134-
/**
135-
* Performs the Platform.getDebugOption true check on the provided trace
136-
* <p>
137-
* Note: ProjectUIPlugin.getDefault().isDebugging() must also be on.
138-
* <ul>
139-
* <li>Trace.RENDER - trace rendering progress
140-
* </ul>
141-
* </p>
142-
*
143-
* @param trace currently only RENDER is defined
144-
*/
145-
public static boolean isDebugging( final String trace ) {
146-
return getDefault().isDebugging()
147-
&& "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$
148-
}
149100
}

plugins/org.locationtech.udig.catalog.csw/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bundle-Name: Csw
44
Bundle-SymbolicName: org.locationtech.udig.catalog.csw;singleton:=true
55
Bundle-Version: 2.3.0.qualifier
66
Bundle-Vendor: udig.refractions.net
7-
Bundle-Activator: org.locationtech.udig.catalog.csw.Activator
7+
Bundle-Activator: org.locationtech.udig.catalog.csw.CswPlugin
88
Require-Bundle: org.eclipse.core.runtime,
99
org.locationtech.udig.catalog,
1010
org.locationtech.udig.catalog.ui

0 commit comments

Comments
 (0)