Skip to content

Commit

Permalink
Feature : LoggingSupport
Browse files Browse the repository at this point in the history
for logging & tracing the same way for all modules

Signed-off-by: Frank Gasdorf <[email protected]>
  • Loading branch information
fgdrf committed Nov 6, 2021
1 parent e0533da commit 60c7049
Show file tree
Hide file tree
Showing 345 changed files with 9,689 additions and 10,803 deletions.
Binary file added docs/__pycache__/common.cpython-39.pyc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,48 @@
import org.osgi.framework.BundleContext;

public class ArcGridPlugin extends AbstractUIPlugin {
private static ArcGridPlugin plugin;
private ResourceBundle resourceBundle;

public ArcGridPlugin() {
super();
plugin = this;
}

public void start(BundleContext context) throws Exception {
super.start(context);
}

public void stop(BundleContext context) throws Exception {
plugin = null;
this.resourceBundle = null;
super.stop(context);
}

public static ArcGridPlugin getDefault() {
return plugin;
}

public static String getResourceString(String key) {
ResourceBundle bundle = ArcGridPlugin.getDefault().getResourceBundle();
try {
return (bundle != null) ? bundle.getString(key) : key;
} catch (MissingResourceException e) {
return key;
}
}

public ResourceBundle getResourceBundle() {
try {
if (this.resourceBundle == null)
this.resourceBundle = ResourceBundle.getBundle(
private static ArcGridPlugin plugin;

private ResourceBundle resourceBundle;

public ArcGridPlugin() {
super();
plugin = this;
}

@Override
public void start(BundleContext context) throws Exception {
super.start(context);
}

@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
this.resourceBundle = null;
super.stop(context);
}

public static ArcGridPlugin getDefault() {
return plugin;
}

public static String getResourceString(String key) {
ResourceBundle bundle = ArcGridPlugin.getDefault().getResourceBundle();
try {
return (bundle != null) ? bundle.getString(key) : key;
} catch (MissingResourceException e) {
return key;
}
}

public ResourceBundle getResourceBundle() {
try {
if (this.resourceBundle == null)
this.resourceBundle = ResourceBundle.getBundle(
"org.locationtech.udig.arcgrid.internal.arcgrid.ArcGridPluginResources"); //$NON-NLS-1$
} catch (MissingResourceException x) {
this.resourceBundle = null;
}
return this.resourceBundle;
}
} catch (MissingResourceException x) {
this.resourceBundle = null;
}
return this.resourceBundle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,34 @@
import java.util.List;
import java.util.Map;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.geotools.arcsde.data.ArcSDEDataStoreConfig;
import org.geotools.arcsde.session.ArcSDEConnectionConfig;
import org.geotools.data.DataStore;
import org.locationtech.udig.catalog.CatalogPlugin;
import org.locationtech.udig.catalog.IGeoResource;
import org.locationtech.udig.catalog.IResolveChangeEvent;
import org.locationtech.udig.catalog.IResolveDelta;
import org.locationtech.udig.catalog.IService;
import org.locationtech.udig.catalog.IServiceInfo;
import org.locationtech.udig.catalog.IResolve.Status;
import org.locationtech.udig.catalog.internal.CatalogImpl;
import org.locationtech.udig.catalog.internal.ResolveChangeEvent;
import org.locationtech.udig.catalog.internal.ResolveDelta;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.geotools.arcsde.data.ArcSDEDataStoreConfig;
import org.geotools.arcsde.session.ArcSDEConnectionConfig;
import org.geotools.data.DataStore;
import org.locationtech.udig.core.logging.LoggingSupport;

/**
* Connect to ArcSDE.
*
*
* @author David Zwiers, Refractions Research
* @since 0.6
*/
public class ArcServiceImpl extends IService {

/** Identifier used in Catalog */
private final URL url;

/** Current connection error - if any */
private Throwable msg;

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

/** List of child members, provided by {@link #vectorService} and {@link #rasterService}. */
private volatile List<IGeoResource> members;

/**
* ArcSDE DataStore details used for connection.
*/
private final ArcSDEDataStoreConfig dataStoreConfig;

/**
* Construct <code>PostGISServiceImpl</code>.
*
*
* @param url
* @param params
*/
Expand All @@ -84,6 +83,7 @@ public ArcServiceImpl( URL url, Map<String, Serializable> params ) {
/**
* @see IService#resolve(Class, IProgressMonitor)
*/
@Override
public <T> T resolve( final Class<T> adaptee, IProgressMonitor monitor ) throws IOException {
if (monitor == null) {
monitor = new NullProgressMonitor();
Expand Down Expand Up @@ -111,6 +111,7 @@ public <T> T resolve( final Class<T> adaptee, IProgressMonitor monitor ) throws
/**
* @see org.locationtech.udig.catalog.IResolve#canResolve(Class)
*/
@Override
public <T> boolean canResolve( Class<T> adaptee ) {
if (adaptee == null) {
return false;
Expand All @@ -123,7 +124,7 @@ public <T> boolean canResolve( Class<T> adaptee ) {
// }
return super.canResolve(adaptee);
}

/**
* @see IService#resources(IProgressMonitor)
*/
Expand All @@ -132,7 +133,7 @@ public List<IGeoResource> resources( final IProgressMonitor monitor ) throws IOE
if (members == null) {
synchronized (this) {
if (members == null) {
members = new ArrayList<IGeoResource>();
members = new ArrayList<>();
if (vectorService != null) {
members.addAll(vectorService.resources(monitor));
}
Expand Down Expand Up @@ -177,13 +178,15 @@ protected IServiceInfo createInfo( IProgressMonitor monitor ) throws IOException
/**
* @see IService#getConnectionParams()
*/
@Override
public Map<String, Serializable> getConnectionParams() {
return dataStoreConfig == null ? null : dataStoreConfig.toMap();
}

/**
* @see IService#getStatus()
*/
@Override
public Status getStatus() {
if( vectorService == null ){
return super.getStatus();
Expand All @@ -194,13 +197,15 @@ public Status getStatus() {
/**
* @see IService#getMessage()
*/
@Override
public Throwable getMessage() {
return msg;
}

/**
* @see IService#getIdentifier()
*/
@Override
public URL getIdentifier() {
return url;
}
Expand All @@ -218,24 +223,26 @@ public ArcSDEVectorService getVectorService() {
}

private static class IServiceArcSDEInfo extends IServiceInfo {

private final URL identifier;

IServiceArcSDEInfo( final URL identifier, final ArcSDEConnectionConfig connectionConfig ) {
this.identifier = identifier;
try {
schema = new URI("arcsde://geotools/gml"); //$NON-NLS-1$
} catch (URISyntaxException e) {
ArcsdePlugin.log(null, e);
LoggingSupport.log(ArcsdePlugin.getDefault(), e);
}
icon = AbstractUIPlugin.imageDescriptorFromPlugin(ArcsdePlugin.ID,
"icons/obj16/arcsde_obj.gif"); //$NON-NLS-1$
}


@Override
public String getDescription() {
return identifier.toString();
}


@Override
public URI getSource() {
try {
return identifier.toURI();
Expand All @@ -244,10 +251,11 @@ public URI getSource() {
throw (RuntimeException) new RuntimeException().initCause(e);
}
}


@Override
public String getTitle() {
return "ARCSDE " + identifier.getHost(); //$NON-NLS-1$
}

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2012, Refractions Research Inc.
/**
* uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2012, Refractions Research Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -13,9 +13,6 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

Expand Down Expand Up @@ -46,13 +43,15 @@ public ArcsdePlugin() {
/**
* This method is called upon plug-in activation
*/
@Override
public void start( BundleContext context ) throws Exception {
super.start(context);
}

/**
* This method is called when the plug-in is stopped
*/
@Override
public void stop( BundleContext context ) throws Exception {
plugin = null;
resourceBundle = null;
Expand All @@ -61,7 +60,7 @@ public void stop( BundleContext context ) throws Exception {

/**
* Returns the shared instance.
*
*
* @return x
*/
public static ArcsdePlugin getDefault() {
Expand All @@ -70,7 +69,7 @@ public static ArcsdePlugin getDefault() {

/**
* Returns the string from the plugin's resource bundle, or 'key' if not found.
*
*
* @param key
* @return x
*/
Expand All @@ -85,7 +84,7 @@ public static String getResourceString( String key ) {

/**
* Returns the plugin's resource bundle,
*
*
* @return x
*/
public ResourceBundle getResourceBundle() {
Expand All @@ -98,52 +97,4 @@ public ResourceBundle getResourceBundle() {
}
return resourceBundle;
}

/**
* Logs the Throwable in the plugin's log.
* <p>
* This will be a user visable ERROR iff:
* <ul>
* <li>t is an Exception we are assuming it is human readable or if a message is provided
*/
public static void log( String message, Throwable t ) {
int status = t instanceof Exception || message != null ? IStatus.ERROR : IStatus.WARNING;
getDefault().getLog().log(new Status(status, ID, IStatus.OK, message, t));
}

/**
* Messages that only engage if getDefault().isDebugging()
* <p>
* It is much prefered to do this:
*
* <pre><code>
* private static final String RENDERING = &quot;org.locationtech.udig.project/render/trace&quot;;
* if (ProjectUIPlugin.getDefault().isDebugging() &amp;&amp; &quot;true&quot;.equalsIgnoreCase(RENDERING)) {
* System.out.println(&quot;your message here&quot;);
* }
*/
public static void trace( String message, Throwable e ) {
if (getDefault().isDebugging()) {
if (message != null)
System.out.println(message);
if (e != null)
e.printStackTrace();
}
}

/**
* Performs the Platform.getDebugOption true check on the provided trace
* <p>
* Note: ProjectUIPlugin.getDefault().isDebugging() must also be on.
* <ul>
* <li>Trace.RENDER - trace rendering progress
* </ul>
* </p>
*
* @param trace currently only RENDER is defined
*/
public static boolean isDebugging( final String trace ) {
return getDefault().isDebugging()
&& "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: Csw
Bundle-SymbolicName: org.locationtech.udig.catalog.csw;singleton:=true
Bundle-Version: 2.3.0.qualifier
Bundle-Vendor: udig.refractions.net
Bundle-Activator: org.locationtech.udig.catalog.csw.Activator
Bundle-Activator: org.locationtech.udig.catalog.csw.CswPlugin
Require-Bundle: org.eclipse.core.runtime,
org.locationtech.udig.catalog,
org.locationtech.udig.catalog.ui
Expand Down
Loading

0 comments on commit 60c7049

Please sign in to comment.