Package aQute.bnd.url
Class DefaultURLConnectionHandler
- java.lang.Object
-
- aQute.bnd.url.DefaultURLConnectionHandler
-
- All Implemented Interfaces:
Plugin,RegistryPlugin,URLConnectionHandler,Report,Reporter
- Direct Known Subclasses:
BasicAuthentication,BearerAuthentication,BndAuthentication,ConnectionSettings,HttpsVerification
public class DefaultURLConnectionHandler extends java.lang.Object implements URLConnectionHandler, Plugin, RegistryPlugin, Reporter
Base class for the URL Connection handlers. This class implements some convenient methods like the matching. In general you should subclass and implementhandle(URLConnection). Be aware to call thematches(URLConnection)method to verify the plugin is applicable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interfaceDefaultURLConnectionHandler.Config-
Nested classes/interfaces inherited from interface aQute.service.reporter.Report
Report.Location
-
Nested classes/interfaces inherited from interface aQute.service.reporter.Reporter
Reporter.SetLocation
-
-
Constructor Summary
Constructors Constructor Description DefaultURLConnectionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DefaultURLConnectionHandleraddMatcher(java.lang.String glob)Reporter.SetLocationerror(java.lang.String format, java.lang.Object... args)Create an error.Reporter.SetLocationexception(java.lang.Throwable t, java.lang.String format, java.lang.Object... args)Dedicated message for an exception.java.util.List<java.lang.String>getErrors()Return the errors.Report.LocationgetLocation(java.lang.String msg)Return the errors for the given error or warning.java.util.List<java.lang.String>getWarnings()Return the warnings.voidhandle(java.net.URLConnection connection)Not doing anything is perfect okbooleanisOk()Check if this report has any relevant errors that should make the run associated with this report invalid.booleanisPedantic()The provider of the reporter wants pedantic reporting, meaning every possible warning should be reported.booleanmatches(java.net.URL url)Verify if the URL matches one of our globs.protected booleanmatches(java.net.URLConnection connection)Convenience method to make it easier to verify connectionsvoidprogress(float progress, java.lang.String format, java.lang.Object... args)Deprecated.Use SLF4J Logger.info() instead.voidsetProperties(java.util.Map<java.lang.String,java.lang.String> map)Set the properties for this plugin.voidsetRegistry(Registry registry)We are a @linkRegistryPluginfor convenience to our subclasses.voidsetReporter(Reporter processor)Set the current reporter.voidtrace(java.lang.String format, java.lang.Object... args)Deprecated.Use SLF4J Logger.debug instead.Reporter.SetLocationwarning(java.lang.String format, java.lang.Object... args)Create a warning.
-
-
-
Method Detail
-
handle
public void handle(java.net.URLConnection connection) throws java.lang.ExceptionNot doing anything is perfect ok- Specified by:
handlein interfaceURLConnectionHandler- Parameters:
connection- The connection to modify- Throws:
java.lang.Exception
-
matches
public boolean matches(java.net.URL url)
Verify if the URL matches one of our globs. If there are no globs, we always return true.- Specified by:
matchesin interfaceURLConnectionHandler- Parameters:
url- the url to match- Returns:
- true if matched, false if not.
-
matches
protected boolean matches(java.net.URLConnection connection)
Convenience method to make it easier to verify connections- Parameters:
connection- The connection to match- Returns:
- true if this connection should be handled.
-
setRegistry
public void setRegistry(Registry registry)
We are a @linkRegistryPluginfor convenience to our subclasses.- Specified by:
setRegistryin interfaceRegistryPlugin
-
setProperties
public void setProperties(java.util.Map<java.lang.String,java.lang.String> map) throws java.lang.ExceptionSet the properties for this plugin. Subclasses should call this method before they handle their own properties.- Specified by:
setPropertiesin interfacePlugin- Parameters:
map- attributes and directives for this plugin's clause- Throws:
java.lang.Exception
-
setReporter
public void setReporter(Reporter processor)
Description copied from interface:PluginSet the current reporter. This is called at init time. This plugin should report all errors and warnings to this reporter.- Specified by:
setReporterin interfacePlugin
-
getWarnings
public java.util.List<java.lang.String> getWarnings()
Description copied from interface:ReportReturn the warnings. This list must not be changed and may be immutable.- Specified by:
getWarningsin interfaceReport- Returns:
- the warnings
-
getErrors
public java.util.List<java.lang.String> getErrors()
Description copied from interface:ReportReturn the errors. This list must not be changed and may be immutable.
-
getLocation
public Report.Location getLocation(java.lang.String msg)
Description copied from interface:ReportReturn the errors for the given error or warning. Can return null.- Specified by:
getLocationin interfaceReport- Parameters:
msg- The message- Returns:
- null or the location of the message
-
isOk
public boolean isOk()
Description copied from interface:ReportCheck if this report has any relevant errors that should make the run associated with this report invalid. I.e. if this returns false then the run should be disregarded.
-
error
public Reporter.SetLocation error(java.lang.String format, java.lang.Object... args)
Description copied from interface:ReporterCreate an error. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.
-
warning
public Reporter.SetLocation warning(java.lang.String format, java.lang.Object... args)
Description copied from interface:ReporterCreate a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.
-
trace
@Deprecated public void trace(java.lang.String format, java.lang.Object... args)Deprecated.Use SLF4J Logger.debug instead.Description copied from interface:ReporterCreate a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.
-
progress
@Deprecated public void progress(float progress, java.lang.String format, java.lang.Object... args)Deprecated.Use SLF4J Logger.info() instead.Description copied from interface:ReporterCreate a warning. Implementations must ensure that the given args are not prevented from garbage collecting. The args must have a proper toString method.
-
exception
public Reporter.SetLocation exception(java.lang.Throwable t, java.lang.String format, java.lang.Object... args)
Description copied from interface:ReporterDedicated message for an exception.
-
isPedantic
public boolean isPedantic()
Description copied from interface:ReporterThe provider of the reporter wants pedantic reporting, meaning every possible warning should be reported.- Specified by:
isPedanticin interfaceReporter- Returns:
- if this is a pedantic reporter.
-
addMatcher
public DefaultURLConnectionHandler addMatcher(java.lang.String glob)
-
-