-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from neva-dev/sdk-fix
SDK fix
- Loading branch information
Showing
5 changed files
with
47 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 42 additions & 8 deletions
50
src/main/java/com/neva/felix/webconsole/plugins/search/SearchActivator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,70 @@ | ||
package com.neva.felix.webconsole.plugins.search; | ||
|
||
import com.neva.felix.webconsole.plugins.search.core.SearchService; | ||
import com.neva.felix.webconsole.plugins.search.plugin.AbstractPlugin; | ||
import com.neva.felix.webconsole.plugins.search.plugin.SearchPlugin; | ||
import com.google.common.collect.ImmutableSet; | ||
import com.neva.felix.webconsole.plugins.search.rest.*; | ||
import org.osgi.framework.BundleActivator; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.framework.ServiceRegistration; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.servlet.Servlet; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class SearchActivator implements BundleActivator { | ||
|
||
private SearchHttpTracker httpTracker; | ||
private static final Logger LOG = LoggerFactory.getLogger(SearchActivator.class); | ||
|
||
private final List<ServiceRegistration> services = new LinkedList<>(); | ||
|
||
@Override | ||
public void start(BundleContext bundleContext) throws Exception { | ||
for (AbstractPlugin plugin : getPlugins(bundleContext)) { | ||
plugin.register(); | ||
ServiceRegistration service = bundleContext.registerService(Servlet.class.getName(), plugin, plugin.getProps()); | ||
if (service != null) { | ||
services.add(service); | ||
} else { | ||
LOG.error("Cannot register plugin '{}' as OSGi service", plugin.getClass().getName()); | ||
} | ||
} | ||
for (RestServlet servlet : getServlets(bundleContext)) { | ||
ServiceRegistration service = bundleContext.registerService(Servlet.class.getName(), servlet, servlet.createProps()); | ||
if (service != null) { | ||
services.add(service); | ||
} else { | ||
LOG.error("Cannot register plugin servlet '{}' as OSGi service", servlet.getClass().getName()); | ||
} | ||
} | ||
|
||
httpTracker = new SearchHttpTracker(bundleContext); | ||
httpTracker.open(); | ||
} | ||
|
||
@Override | ||
public void stop(BundleContext bundleContext) throws Exception { | ||
httpTracker.close(); | ||
httpTracker = null; | ||
for (ServiceRegistration service : services) { | ||
service.unregister(); | ||
} | ||
} | ||
|
||
private Set<AbstractPlugin> getPlugins(BundleContext bundleContext) { | ||
return ImmutableSet.<AbstractPlugin>of( | ||
return ImmutableSet.of( | ||
new SearchPlugin(bundleContext) | ||
); | ||
} | ||
|
||
private ImmutableSet<RestServlet> getServlets(BundleContext context) { | ||
return ImmutableSet.of( | ||
new ByPhraseServlet(context), | ||
new BundleDownloadServlet(context), | ||
new BundleClassesServlet(context), | ||
new ClassDecompileServlet(context), | ||
new ClassSearchServlet(context), | ||
new SourceGenerateServlet(context), | ||
new FileDownloadServlet(context), | ||
new BundleAssembleServlet(context) | ||
); | ||
} | ||
} |
65 changes: 0 additions & 65 deletions
65
src/main/java/com/neva/felix/webconsole/plugins/search/SearchHttpTracker.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters