Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply project settings to o.e.equinox.http.registry #357

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.equinox.http.registry;singleton:=true
Bundle-Version: 1.3.300.qualifier
Bundle-Version: 1.3.400.qualifier
Bundle-Activator: org.eclipse.equinox.http.registry.internal.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.equinox.common,
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.equinox.http.registry/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ <h3>License</h3>
</p>

</body>
</html>
</html>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# To force a version qualifier update add the bug here
Bug 403352 - Update all parent versions to match our build stream
Bug 527899 [9] Implement JEP 280: Indify String Concatenation #1139
Bug 527899 [9] Implement JEP 280: Indify String Concatenation #1139
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@
import org.osgi.service.http.HttpService;

/**
* The HttpContextExtensionService provides access to an HttpContext instance whose resources and implementation
* are added via the "httpcontexts" extension point.
* The HttpContextExtensionService provides access to an HttpContext instance
* whose resources and implementation are added via the "httpcontexts" extension
* point.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface HttpContextExtensionService {
/**
* returns the HttpContext associated with the HttpService reference and http context name
* returns the HttpContext associated with the HttpService reference and http
* context name
*
* @param httpServiceReference The ServiceReference of the http service to which this HttpContext applies
* @param httpContextId The name of the HttpContext. Must be provided
* @param httpServiceReference The ServiceReference of the http service to which
* this HttpContext applies
* @param httpContextId The name of the HttpContext. Must be provided
*
* @return The HttpContext associated with the "id" and Http Service Reference; <code>null</code>
* if the HttpContext is unavailable.
* @return The HttpContext associated with the "id" and Http Service Reference;
* <code>null</code> if the HttpContext is unavailable.
*/
public HttpContext getHttpContext(ServiceReference<HttpService> httpServiceReference, String httpContextId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings({ "rawtypes", "unchecked" })
public class Activator implements BundleActivator, ServiceTrackerCustomizer {

private ServiceTracker httpServiceTracker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,19 @@ private String sanitizeEntryName(String name) {
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
switch (c) {
case '*' :
case '\\' :
// we need to escape '*' and '\'
if (buffer == null) {
buffer = new StringBuffer(name.length() + 16);
buffer.append(name.substring(0, i));
}
buffer.append('\\').append(c);
break;
default :
if (buffer != null)
buffer.append(c);
break;
case '*':
case '\\':
// we need to escape '*' and '\'
if (buffer == null) {
buffer = new StringBuffer(name.length() + 16);
buffer.append(name.substring(0, i));
}
buffer.append('\\').append(c);
break;
default:
if (buffer != null)
buffer.append(c);
break;
}
}
return (buffer == null) ? name : buffer.toString();
Expand All @@ -169,4 +169,4 @@ public Set<String> getResourcePaths(String path) {
return result;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public interface Listener {

private static final Listener NULL_LISTENER = new Listener() {
public void added(IExtension extension) {
//empty
// empty
}

public void removed(IExtension extension) {
//empty
// empty
}
};

Expand Down Expand Up @@ -122,17 +122,17 @@ public void registryChanged(IRegistryChangeEvent event) {
for (IExtensionDelta delta : deltas) {
IExtension extension = delta.getExtension();
switch (delta.getKind()) {
case IExtensionDelta.ADDED :
if (addExtension(extension)) {
listener.added(extension);
}
break;
case IExtensionDelta.REMOVED :
if (removeExtension(extension)) {
listener.removed(extension);
}
default :
break;
case IExtensionDelta.ADDED:
if (addExtension(extension)) {
listener.added(extension);
}
break;
case IExtensionDelta.REMOVED:
if (removeExtension(extension)) {
listener.removed(extension);
}
default:
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public class FilterManager implements ExtensionPointTracker.Listener {

private ServiceReference<?> reference;

public FilterManager(HttpRegistryManager httpRegistryManager, ServiceReference<?> reference, IExtensionRegistry registry) {
public FilterManager(HttpRegistryManager httpRegistryManager, ServiceReference<?> reference,
IExtensionRegistry registry) {
this.httpRegistryManager = httpRegistryManager;
this.reference = reference;
tracker = new ExtensionPointTracker(registry, FILTERS_EXTENSION_POINT, this);
Expand All @@ -78,7 +79,8 @@ public void added(IExtension extension) {
String clazz = serviceSelectorElement.getAttribute(CLASS);
if (clazz != null) {
try {
serviceSelector = (org.osgi.framework.Filter) serviceSelectorElement.createExecutableExtension(CLASS);
serviceSelector = (org.osgi.framework.Filter) serviceSelectorElement
.createExecutableExtension(CLASS);
} catch (CoreException e) {
// log it.
e.printStackTrace();
Expand Down Expand Up @@ -133,7 +135,8 @@ public void added(IExtension extension) {
if (httpContextId != null && httpContextId.indexOf('.') == -1)
httpContextId = filterElement.getNamespaceIdentifier() + "." + httpContextId; //$NON-NLS-1$

if (httpRegistryManager.addFilterContribution(alias, wrapper, initparams, httpContextId, extension.getContributor()))
if (httpRegistryManager.addFilterContribution(alias, wrapper, initparams, httpContextId,
extension.getContributor()))
registered.put(filterElement, wrapper);
}
}
Expand Down Expand Up @@ -168,7 +171,8 @@ public void init(FilterConfig filterConfig) throws ServletException {
initializeDelegate();
}

public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain) throws ServletException, IOException {
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain)
throws ServletException, IOException {
initializeDelegate();
delegate.doFilter(arg0, arg1, chain);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class ServletContribution {
String httpContextId;
IContributor contributor;

public ServletContribution(String alias, Servlet servlet, Dictionary<?, ?> initparams, String httpContextId, IContributor contributor) {
public ServletContribution(String alias, Servlet servlet, Dictionary<?, ?> initparams, String httpContextId,
IContributor contributor) {
this.alias = alias;
this.servlet = servlet;
this.initparams = initparams;
Expand All @@ -62,7 +63,8 @@ class FilterContribution {
String httpContextId;
IContributor contributor;

public FilterContribution(String alias, javax.servlet.Filter filter, Dictionary<?, ?> initparams, String httpContextId, IContributor contributor) {
public FilterContribution(String alias, javax.servlet.Filter filter, Dictionary<?, ?> initparams,
String httpContextId, IContributor contributor) {
this.alias = alias;
this.filter = filter;
this.initparams = initparams;
Expand Down Expand Up @@ -93,7 +95,8 @@ public HttpContextContribution(HttpContext context, IContributor contributor) {
private Map<String, ResourcesContribution> resources = new HashMap<>();
private Set<String> registered = new HashSet<>();

public HttpRegistryManager(ServiceReference<?> reference, HttpService httpService, PackageAdmin packageAdmin, IExtensionRegistry registry) {
public HttpRegistryManager(ServiceReference<?> reference, HttpService httpService, PackageAdmin packageAdmin,
IExtensionRegistry registry) {
this.httpService = httpService;
this.packageAdmin = packageAdmin;

Expand All @@ -117,9 +120,11 @@ public void stop() {
httpContextManager.stop();
}

public synchronized boolean addResourcesContribution(String alias, String baseName, String httpContextId, IContributor contributor) {
public synchronized boolean addResourcesContribution(String alias, String baseName, String httpContextId,
IContributor contributor) {
if (resources.containsKey(alias) || servlets.containsKey(alias)) {
System.err.println("ERROR: Duplicate alias. Failed to register resource for [alias=\"" + alias + "\", contributor=\"" + contributor + "\"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.err.println("ERROR: Duplicate alias. Failed to register resource for [alias=\"" + alias //$NON-NLS-1$
+ "\", contributor=\"" + contributor + "\"]"); //$NON-NLS-1$ //$NON-NLS-2$
return false;
}

Expand All @@ -131,13 +136,16 @@ public synchronized boolean addResourcesContribution(String alias, String baseNa
return true;
}

public synchronized boolean addServletContribution(String alias, Servlet servlet, Dictionary<?, ?> initparams, String httpContextId, IContributor contributor) {
public synchronized boolean addServletContribution(String alias, Servlet servlet, Dictionary<?, ?> initparams,
String httpContextId, IContributor contributor) {
if (resources.containsKey(alias) || servlets.containsKey(alias)) {
System.err.println("ERROR: Duplicate alias. Failed to register servlet for [alias=\"" + alias + "\", contributor=\"" + contributor + "\"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.err.println("ERROR: Duplicate alias. Failed to register servlet for [alias=\"" + alias //$NON-NLS-1$
+ "\", contributor=\"" + contributor + "\"]"); //$NON-NLS-1$ //$NON-NLS-2$
return false;
}

ServletContribution contribution = new ServletContribution(alias, servlet, initparams, httpContextId, contributor);
ServletContribution contribution = new ServletContribution(alias, servlet, initparams, httpContextId,
contributor);
servlets.put(alias, contribution);
if (httpContextId == null || contexts.containsKey(httpContextId))
registerServlet(contribution);
Expand All @@ -151,7 +159,8 @@ public synchronized void removeContribution(String alias) {
unregister(alias);
}

public synchronized boolean addFilterContribution(String alias, javax.servlet.Filter filter, Dictionary<?, ?> initparams, String httpContextId, IContributor contributor) {
public synchronized boolean addFilterContribution(String alias, javax.servlet.Filter filter,
Dictionary<?, ?> initparams, String httpContextId, IContributor contributor) {
FilterContribution contribution = new FilterContribution(alias, filter, initparams, httpContextId, contributor);
return registerFilter(contribution);
}
Expand All @@ -174,9 +183,11 @@ public synchronized HttpContext getHttpContext(String httpContextId, Bundle bund
return contribution.context;
}

public synchronized boolean addHttpContextContribution(String httpContextId, HttpContext context, IContributor contributor) {
public synchronized boolean addHttpContextContribution(String httpContextId, HttpContext context,
IContributor contributor) {
if (contexts.containsKey(httpContextId)) {
System.err.println("ERROR: Duplicate HttpContextId. Failed to register HttpContext for [httpContextId=\"" + httpContextId + "\", contributor=\"" + contributor + "\"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.err.println("ERROR: Duplicate HttpContextId. Failed to register HttpContext for [httpContextId=\"" //$NON-NLS-1$
+ httpContextId + "\", contributor=\"" + contributor + "\"]"); //$NON-NLS-1$ //$NON-NLS-2$
return false;
}

Expand Down Expand Up @@ -231,7 +242,7 @@ public Bundle getBundle(String symbolicName) {
Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
if (bundles == null)
return null;
//Return the first bundle that is not installed or uninstalled
// Return the first bundle that is not installed or uninstalled
for (Bundle bundle : bundles) {
if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
return bundle;
Expand Down Expand Up @@ -285,14 +296,18 @@ private boolean registerFilter(FilterContribution contribution) {
Method registerFilterMethod = null;
try {
// First, try the Equinox http service method
registerFilterMethod = httpService.getClass().getMethod("registerFilter", new Class[] {String.class, Filter.class, Dictionary.class, HttpContext.class}); //$NON-NLS-1$
registerFilterMethod.invoke(httpService, new Object[] {contribution.alias, contribution.filter, contribution.initparams, context});
registerFilterMethod = httpService.getClass().getMethod("registerFilter", //$NON-NLS-1$
new Class[] { String.class, Filter.class, Dictionary.class, HttpContext.class });
registerFilterMethod.invoke(httpService,
new Object[] { contribution.alias, contribution.filter, contribution.initparams, context });
return true;
} catch (NoSuchMethodException e) {
// Give the pax-web HttpService impl a try
try {
registerFilterMethod = httpService.getClass().getMethod("registerFilter", new Class[] {Filter.class, String[].class, String[].class, Dictionary.class, HttpContext.class}); //$NON-NLS-1$
registerFilterMethod.invoke(httpService, new Object[] {contribution.filter, new String[] {contribution.alias}, null, contribution.initparams, context});
registerFilterMethod = httpService.getClass().getMethod("registerFilter", new Class[] { Filter.class, //$NON-NLS-1$
String[].class, String[].class, Dictionary.class, HttpContext.class });
registerFilterMethod.invoke(httpService, new Object[] { contribution.filter,
new String[] { contribution.alias }, null, contribution.initparams, context });
return true;
} catch (Throwable t) {
// TODO: should log this
Expand All @@ -309,8 +324,9 @@ private boolean registerFilter(FilterContribution contribution) {

private void unregisterFilter(Filter filter) {
try {
Method unregisterFilterMethod = httpService.getClass().getMethod("unregisterFilter", new Class[] {Filter.class}); //$NON-NLS-1$
unregisterFilterMethod.invoke(httpService, new Object[] {filter});
Method unregisterFilterMethod = httpService.getClass().getMethod("unregisterFilter", //$NON-NLS-1$
new Class[] { Filter.class });
unregisterFilterMethod.invoke(httpService, new Object[] { filter });
} catch (NoSuchMethodException t) {
// TODO: should log this
// for now ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public HttpServiceTracker(BundleContext context, PackageAdmin packageAdmin, IExt

public void open() {
super.open();
registration = context.registerService(HttpContextExtensionService.class.getName(), new HttpContextExtensionServiceFactory(), null);
registration = context.registerService(HttpContextExtensionService.class.getName(),
new HttpContextExtensionServiceFactory(), null);
}

public void close() {
Expand All @@ -57,7 +58,8 @@ public synchronized HttpService addingService(ServiceReference<HttpService> refe
if (httpService == null)
return null;

HttpRegistryManager httpRegistryManager = new HttpRegistryManager(reference, httpService, packageAdmin, registry);
HttpRegistryManager httpRegistryManager = new HttpRegistryManager(reference, httpService, packageAdmin,
registry);
httpRegistryManager.start();
httpRegistryManagers.put(reference, httpRegistryManager);

Expand All @@ -78,11 +80,13 @@ public synchronized void removedService(ServiceReference<HttpService> reference,

public class HttpContextExtensionServiceFactory implements ServiceFactory<HttpContextExtensionService> {

public HttpContextExtensionService getService(Bundle bundle, ServiceRegistration<HttpContextExtensionService> registration) {
public HttpContextExtensionService getService(Bundle bundle,
ServiceRegistration<HttpContextExtensionService> registration) {
return new HttpContextExtensionServiceImpl(bundle);
}

public void ungetService(Bundle bundle, ServiceRegistration<HttpContextExtensionService> registration, HttpContextExtensionService service) {
public void ungetService(Bundle bundle, ServiceRegistration<HttpContextExtensionService> registration,
HttpContextExtensionService service) {
// do nothing
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class ResourceManager implements ExtensionPointTracker.Listener {

private ServiceReference<?> reference;

public ResourceManager(HttpRegistryManager httpRegistryManager, ServiceReference<?> reference, IExtensionRegistry registry) {
public ResourceManager(HttpRegistryManager httpRegistryManager, ServiceReference<?> reference,
IExtensionRegistry registry) {
this.httpRegistryManager = httpRegistryManager;
this.reference = reference;
tracker = new ExtensionPointTracker(registry, RESOURCES_EXTENSION_POINT, this);
Expand All @@ -72,7 +73,8 @@ public void added(IExtension extension) {
String clazz = serviceSelectorElement.getAttribute(CLASS);
if (clazz != null) {
try {
serviceSelector = (org.osgi.framework.Filter) serviceSelectorElement.createExecutableExtension(CLASS);
serviceSelector = (org.osgi.framework.Filter) serviceSelectorElement
.createExecutableExtension(CLASS);
} catch (CoreException e) {
// log it.
e.printStackTrace();
Expand Down Expand Up @@ -118,7 +120,8 @@ public void added(IExtension extension) {
if (httpContextId != null && httpContextId.indexOf('.') == -1)
httpContextId = resourceElement.getNamespaceIdentifier() + "." + httpContextId; //$NON-NLS-1$

if (httpRegistryManager.addResourcesContribution(alias, baseName, httpContextId, extension.getContributor()))
if (httpRegistryManager.addResourcesContribution(alias, baseName, httpContextId,
extension.getContributor()))
registered.add(resourceElement);
}
}
Expand Down
Loading
Loading