Browse files

more logging, open more doors to register filter factories

  • Loading branch information...
1 parent 987fbaa commit 5826e52eeabcd9156fd2869fac33c8f78cdc6f2e @atoulme atoulme committed May 20, 2011
View
107 designer/src/main/java/org/wapama/web/Activator.java
@@ -51,71 +51,62 @@ public void start(final BundleContext context) throws Exception {
{
ServiceReference sRef =
context.getServiceReference(IDiagramPreferenceService.class.getName());
- if (sRef != null) {
- IDiagramPreferenceService service = (IDiagramPreferenceService) context.getService(sRef);
- EditorHandler.PREFERENCE_FACTORY = service;
- } else {
- //use a service tracker to be called back when the IUUIDBasedRepositoryFactory is ready:
- ServiceTrackerCustomizer cust = new ServiceTrackerCustomizer() {
-
- public void removedService(ServiceReference reference, Object service) {
- //special servlet shutdown
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- //reload?
- }
-
- public Object addingService(ServiceReference reference) {
- IDiagramPreferenceService service = (IDiagramPreferenceService) context.getService(reference);
- EditorHandler.PREFERENCE_FACTORY = service;
- return service;
- }
- };
- ServiceTracker tracker = new ServiceTracker(context,
- IDiagramPreferenceService.class.getName(), cust);
- tracker.open();
-
- }
+ IDiagramPreferenceService service = (IDiagramPreferenceService) context.getService(sRef);
+ EditorHandler.PREFERENCE_FACTORY = service;
+ //use a service tracker to be called back when the IUUIDBasedRepositoryFactory is ready:
+ ServiceTrackerCustomizer cust = new ServiceTrackerCustomizer() {
+
+ public void removedService(ServiceReference reference, Object service) {
+ //special servlet shutdown
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ //reload?
+ }
+
+ public Object addingService(ServiceReference reference) {
+ IDiagramPreferenceService service = (IDiagramPreferenceService) context.getService(reference);
+ EditorHandler.PREFERENCE_FACTORY = service;
+ return service;
+ }
+ };
+ ServiceTracker tracker = new ServiceTracker(context,
+ IDiagramPreferenceService.class.getName(), cust);
+ tracker.open();
}
{
- ServiceReference sRef =
- context.getServiceReference(IFilterFactory.class.getName());
- if (sRef != null) {
- IFilterFactory service = (IFilterFactory) context.getService(sRef);
- PluggableFilter.registerFilter(service);
- } else {
- //use a service tracker to be called back when the IFilterFactory is ready:
- ServiceTrackerCustomizer cust = new ServiceTrackerCustomizer() {
-
- public void removedService(ServiceReference reference, Object service) {
- //special servlet shutdown
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- //reload?
- }
-
- public Object addingService(ServiceReference reference) {
- IFilterFactory service = (IFilterFactory) context.getService(reference);
- PluggableFilter.registerFilter(service);
- return service;
- }
- };
- ServiceTracker tracker = new ServiceTracker(context,
- IFilterFactory.class.getName(), cust);
- tracker.open();
-
+ ServiceReference[] sRefs = context.getServiceReferences(IFilterFactory.class.getName(), null);
+ if (sRefs != null) {
+ for (ServiceReference sRef : sRefs) {
+ IFilterFactory service = (IFilterFactory) context.getService(sRef);
+ PluggableFilter.registerFilter(service);
+ }
}
+ //use a service tracker to be called back when the IFilterFactory is ready:
+ ServiceTrackerCustomizer cust = new ServiceTrackerCustomizer() {
+
+ public void removedService(ServiceReference reference, Object service) {
+ //special servlet shutdown
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ //reload?
+ }
+
+ public Object addingService(ServiceReference reference) {
+ IFilterFactory service = (IFilterFactory) context.getService(reference);
+ PluggableFilter.registerFilter(service);
+ return service;
+ }
+ };
+ ServiceTracker tracker = new ServiceTracker(context,
+ IFilterFactory.class.getName(), cust);
+ tracker.open();
}
{
- ServiceReference[] sRefs = null;
- try {
- sRefs = context.getServiceReferences(IDiagramProfileFactory.class.getName(), null);
- } catch (InvalidSyntaxException e) {
- }
+ ServiceReference[] sRefs = context.getServiceReferences(IDiagramProfileFactory.class.getName(), null);
if (sRefs != null) {
for (ServiceReference sRef : sRefs) {
IDiagramProfileFactory service = (IDiagramProfileFactory) context.getService(sRef);
View
10 designer/src/main/java/org/wapama/web/filter/impl/PluggableFilter.java
@@ -32,6 +32,8 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.wapama.web.filter.ConfigurableFilterConfig;
import org.wapama.web.filter.IFilterFactory;
@@ -44,32 +46,39 @@
*/
public class PluggableFilter implements Filter {
+ private static final Logger _logger = LoggerFactory.getLogger(PluggableFilter.class);
+
private static List<IFilterFactory> _registeredFilters = new ArrayList<IFilterFactory>();
private List<Filter> _filters = new ArrayList<Filter>();
private FilterConfig _filterConfig;
public static void registerFilter(IFilterFactory filter) {
+ _logger.debug("Registering new filter factory {}", filter);
_registeredFilters.add(filter);
}
public void init(FilterConfig filterConfig) throws ServletException {
+ _logger.debug("Initialized the Pluggable filter");
_filterConfig = filterConfig;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (_filters.size() != _registeredFilters.size()) {
+ _logger.debug("Initializing loggers from logger factories");
for (Filter f : _filters) {
f.destroy();
}
_filters.clear();
for (IFilterFactory f : _registeredFilters) {
+ _logger.debug("Initializing filter {}", f);
Filter filter = f.createFilter();
ConfigurableFilterConfig config = new ConfigurableFilterConfig(_filterConfig);
f.configureFilterConfig(config);
filter.init(config);
_filters.add(filter);
}
+ _logger.debug("Done initializing loggers from logger factories");
}
new FilterChainImpl(_filters, chain).doFilter(request, response);
if (!response.isCommitted()) {
@@ -78,6 +87,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
}
public void destroy() {
+ _logger.debug("Destroying pluggable filter");
for (Filter filter : _filters) {
filter.destroy();
}

0 comments on commit 5826e52

Please sign in to comment.