forked from liferay/liferay-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LPS-34598 Optional [conf] when we are retrieving dependencies. We wil…
…l use this approach to handle provided dependencies in the OSGi bundles
- Loading branch information
1 parent
7252b6d
commit 11d9466
Showing
48 changed files
with
6,356 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<classpath> | ||
<classpathentry excluding="**/.svn/**|.svn/" kind="src" path="src" /> | ||
<classpathentry kind="src" path="/portal-master" /> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" /> | ||
<classpathentry excluding="**/.svn/**|.svn/" kind="src" path="test/unit" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/junit.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/mockito.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/powermock-mockito.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/spring-test.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/portal/commons-io.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/activation.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/annotations.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/jsp-api.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/mail.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/development/servlet-api.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/global/portlet.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/portal/commons-logging.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/lib/portal/log4j.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/portal-service/portal-service.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/util-bridges/util-bridges.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/util-java/util-java.jar" /> | ||
<classpathentry kind="lib" path="/portal-master/util-taglib/util-taglib.jar" /> | ||
<classpathentry kind="lib" path="lib/log-bridge-shared-6.2.0.1.jar" /> | ||
<classpathentry kind="lib" path="lib/portal-provided/axis.jar" /> | ||
<classpathentry kind="lib" path="lib/portal-provided/org.osgi.compendium.jar" /> | ||
<classpathentry kind="lib" path="lib/portal-provided/org.osgi.core.jar" /> | ||
<classpathentry kind="output" path="bin" /> | ||
</classpath> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/lib/log-bridge-shared-*.jar |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<projectDescription> | ||
<name>http-service-shared-master</name> | ||
<comment></comment> | ||
<projects></projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments></arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Bundle-Activator: com.liferay.httpservice.internal.HttpServiceActivator | ||
Bundle-Name: Http Service | ||
Export-Package:\ | ||
com.liferay.httpservice.servlet,\ | ||
com.liferay.httpservice.ws.* | ||
Import-Package:\ | ||
com.liferay.httpservice.servlet,\ | ||
com.liferay.httpservice.ws.*,\ | ||
* | ||
Include-Resource: classes | ||
Private-Package:\ | ||
com.liferay.httpservice.internal.* |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0"?> | ||
|
||
<project name="http-service-shared" basedir="." default="compile"> | ||
<property name="plugin.version" value="1" /> | ||
|
||
<import file="../../build-common-osgi-plugin.xml" /> | ||
|
||
<property name="import.shared" value="log-bridge-shared" /> | ||
</project> |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ivy-module version="2.0"> | ||
<info organisation="com.liferay" module="http-service-shared" /> | ||
|
||
<configurations> | ||
<conf name="portal-provided" description="This depenndecies will be provided by the portal" /> | ||
</configurations> | ||
|
||
<dependencies> | ||
<dependency name="axis" org="org.apache.axis" rev="1.4" conf="portal-provided->*" /> | ||
<dependency name="org.osgi.compendium" org="org.osgi" rev="4.3.1" conf="portal-provided->*"/> | ||
<dependency name="org.osgi.core" org="org.osgi" rev="4.3.1" conf="portal-provided->*"/> | ||
</dependencies> | ||
</ivy-module> |
167 changes: 167 additions & 0 deletions
167
shared/http-service-shared/src/com/liferay/httpservice/internal/HttpServiceActivator.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 |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/** | ||
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
package com.liferay.httpservice.internal; | ||
|
||
import com.liferay.httpservice.internal.event.EventUtil; | ||
import com.liferay.httpservice.internal.http.PortalHttpContext; | ||
import com.liferay.httpservice.internal.servlet.BundleServletContext; | ||
import com.liferay.httpservice.internal.servlet.WebExtenderServlet; | ||
import com.liferay.httpservice.servlet.BundleServletConfig; | ||
import com.liferay.portal.kernel.log.Log; | ||
import com.liferay.portal.kernel.log.LogFactoryUtil; | ||
import com.liferay.portal.kernel.util.Validator; | ||
|
||
import javax.servlet.ServletConfig; | ||
import javax.servlet.ServletContext; | ||
|
||
import org.osgi.framework.Bundle; | ||
import org.osgi.framework.BundleActivator; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.framework.Filter; | ||
import org.osgi.framework.ServiceReference; | ||
import org.osgi.util.tracker.ServiceTracker; | ||
import org.osgi.util.tracker.ServiceTrackerCustomizer; | ||
|
||
/** | ||
* @author Miguel Pastor | ||
* @author Raymond Augé | ||
*/ | ||
public class HttpServiceActivator | ||
implements BundleActivator, | ||
ServiceTrackerCustomizer<ServletContext, ServletContext> { | ||
|
||
public ServletContext addingService( | ||
ServiceReference<ServletContext> serviceReference) { | ||
|
||
BundleContext bundleContext = getBundleContext(); | ||
|
||
ServletContext servletContext = bundleContext.getService( | ||
serviceReference); | ||
|
||
ServletConfig servletConfig = new BundleServletConfig( | ||
servletContext, "Web Extender Servlet", null, | ||
new PortalHttpContext(servletContext)); | ||
|
||
try { | ||
_webExtenderServlet = new WebExtenderServlet(bundleContext); | ||
|
||
_webExtenderServlet.init(servletConfig); | ||
|
||
_webBundleDeployer = new WebBundleDeployer(_webExtenderServlet); | ||
|
||
_startedBundleListener = new StartedBundleListener( | ||
_webBundleDeployer); | ||
|
||
bundleContext.addBundleListener(_startedBundleListener); | ||
|
||
_stoppedBundleListener = new StoppedBundleListener( | ||
_webBundleDeployer); | ||
|
||
bundleContext.addBundleListener(_stoppedBundleListener); | ||
} | ||
catch (Exception e) { | ||
_log.error(e, e); | ||
} | ||
|
||
checkStartableBundles(); | ||
|
||
return servletContext; | ||
} | ||
|
||
public BundleContext getBundleContext() { | ||
return _bundleContext; | ||
} | ||
|
||
public void modifiedService( | ||
ServiceReference<ServletContext> serviceReference, | ||
ServletContext servletContext) { | ||
} | ||
|
||
public void removedService( | ||
ServiceReference<ServletContext> serviceReference, | ||
ServletContext servletContext) { | ||
|
||
_webBundleDeployer.close(); | ||
|
||
_webBundleDeployer = null; | ||
|
||
_webExtenderServlet.destroy(); | ||
|
||
_webExtenderServlet = null; | ||
|
||
_bundleContext.removeBundleListener(_startedBundleListener); | ||
|
||
_startedBundleListener = null; | ||
|
||
_bundleContext.removeBundleListener(_stoppedBundleListener); | ||
|
||
_stoppedBundleListener = null; | ||
} | ||
|
||
public void start(BundleContext bundleContext) throws Exception { | ||
_bundleContext = bundleContext; | ||
|
||
EventUtil.start(_bundleContext); | ||
|
||
Filter filter = bundleContext.createFilter( | ||
"(&(bean.id=" + ServletContext.class.getName() + | ||
")(original.bean=*))"); | ||
|
||
_servletContextTracker = | ||
new ServiceTracker<ServletContext, ServletContext>( | ||
bundleContext, filter, this); | ||
|
||
_servletContextTracker.open(); | ||
} | ||
|
||
public void stop(BundleContext bundleContext) throws Exception { | ||
_bundleContext = null; | ||
|
||
_servletContextTracker.close(); | ||
|
||
_servletContextTracker = null; | ||
|
||
EventUtil.close(); | ||
} | ||
|
||
protected void checkStartableBundles() { | ||
for (Bundle bundle : _bundleContext.getBundles()) { | ||
String servletContextName = | ||
BundleServletContext.getServletContextName(bundle); | ||
|
||
if (Validator.isNull(servletContextName)) { | ||
continue; | ||
} | ||
|
||
try { | ||
_webBundleDeployer.doStart(bundle, servletContextName); | ||
} | ||
catch (Exception e) { | ||
_log.error(e, e); | ||
} | ||
} | ||
} | ||
|
||
private static Log _log = LogFactoryUtil.getLog(HttpServiceActivator.class); | ||
|
||
private BundleContext _bundleContext; | ||
private StartedBundleListener _startedBundleListener; | ||
private StoppedBundleListener _stoppedBundleListener; | ||
private WebBundleDeployer _webBundleDeployer; | ||
private WebExtenderServlet _webExtenderServlet; | ||
private ServiceTracker<ServletContext, ServletContext> | ||
_servletContextTracker; | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
shared/http-service-shared/src/com/liferay/httpservice/internal/StartedBundleListener.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
package com.liferay.httpservice.internal; | ||
|
||
import com.liferay.httpservice.internal.servlet.BundleServletContext; | ||
import com.liferay.portal.kernel.log.Log; | ||
import com.liferay.portal.kernel.log.LogFactoryUtil; | ||
import com.liferay.portal.kernel.util.Validator; | ||
|
||
import org.osgi.framework.Bundle; | ||
import org.osgi.framework.BundleEvent; | ||
import org.osgi.framework.BundleListener; | ||
|
||
/** | ||
* @author Raymond Augé | ||
* @author Miguel Pastor | ||
*/ | ||
public class StartedBundleListener implements BundleListener { | ||
|
||
public StartedBundleListener(WebBundleDeployer webBundleDeployer) { | ||
_webBundleDeployer = webBundleDeployer; | ||
} | ||
|
||
public void bundleChanged(BundleEvent bundleEvent) { | ||
int type = bundleEvent.getType(); | ||
|
||
Bundle bundle = bundleEvent.getBundle(); | ||
|
||
String servletContextName = BundleServletContext.getServletContextName( | ||
bundle); | ||
|
||
if (Validator.isNull(servletContextName)) { | ||
return; | ||
} | ||
|
||
try { | ||
if (type == BundleEvent.STARTED) { | ||
_webBundleDeployer.doStart(bundle, servletContextName); | ||
} | ||
} | ||
catch (Exception e) { | ||
_log.error(e, e); | ||
} | ||
} | ||
|
||
private static Log _log = LogFactoryUtil.getLog( | ||
StartedBundleListener.class); | ||
|
||
private WebBundleDeployer _webBundleDeployer; | ||
|
||
} |
Oops, something went wrong.