You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2009/04/08 21:25:30 UTC
svn commit: r763357 - in /struts/sandbox/trunk/struts2-osgi-plugin:
admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/
admin-bundle/src/main/resources/osgi/admin/
admin-bundle/src/main/resources/static/ demo-bundle/src/main/java/actions/...
Author: musachy
Date: Wed Apr 8 19:25:30 2009
New Revision: 763357
URL: http://svn.apache.org/viewvc?rev=763357&view=rev
Log:
Fix admin css and add couple of images. Fix plugin bugs
Added:
struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/search.gif (with props)
struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/terminal.gif (with props)
Modified:
struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java
struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/shell.ftl
struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundle.ftl
struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundles.ftl
struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/main.css
struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/java/actions/osgi/HelloWorldAction.java
struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/resources/content/osgi/hello-convention.ftl
struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/DelegatingObjectFactory.java
struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java
struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/SpringOsgiObjectFactory.java
struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/resources/struts-plugin.xml
Modified: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java Wed Apr 8 19:25:30 2009
@@ -28,6 +28,7 @@
import org.apache.struts2.dispatcher.DefaultActionSupport;
import org.apache.struts2.osgi.BundleAccessor;
+import org.apache.struts2.osgi.DefaultBundleAccessor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -42,6 +43,10 @@
private BundleAccessor bundleAccessor;
private Configuration configuration;
+ public BundlesAction() {
+ this.bundleAccessor = DefaultBundleAccessor.getInstance();
+ }
+
public String index() {
return SUCCESS;
}
@@ -95,11 +100,6 @@
return bundleAccessor.getBundles().get(id);
}
- @Inject
- public void setBundleAccessor(BundleAccessor bundleAccessor) {
- this.bundleAccessor = bundleAccessor;
- }
-
public List<PackageConfig> getPackages() {
List<PackageConfig> pkgs = new ArrayList<PackageConfig>();
Bundle bundle = getBundle();
Modified: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/java/org/apache/struts2/osgi/admin/actions/ShellAction.java Wed Apr 8 19:25:30 2009
@@ -49,8 +49,8 @@
String errString = null;
try {
executeCommand(command, outStream, errStream);
- outString = outByteStream.toString();
- errString = errByteStream.toString();
+ outString = outByteStream.toString().trim();
+ errString = errByteStream.toString().trim();
} catch (Exception e) {
errString = e.getMessage();
} finally {
Modified: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/shell.ftl
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/shell.ftl?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/shell.ftl (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/shell.ftl Wed Apr 8 19:25:30 2009
@@ -31,7 +31,11 @@
<body>
<div class="right">
<@s.url var="bundlesUrl" nampespace="/osgi/admin" action="bundles" includeParams="none" />
+ <@s.url var="osgiShellUrl" namespace="/osgi/admin" action="shell" includeParams="none" />
+ <a href="${bundlesUrl}"><img src='<@s.url value="/static/search.gif"/>'</a>
<a href="${bundlesUrl}">Installed Bundles</a>
+ <a href="${bundlesUrl}"><img src='<@s.url value="/static/terminal.gif"/>'</a>
+ <a href="${osgiShellUrl}">OSGi Shell</a>
</div>
<div id="shell" >
<form onsubmit="return false" id="wc-form">
Modified: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundle.ftl
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundle.ftl?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundle.ftl (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundle.ftl Wed Apr 8 19:25:30 2009
@@ -7,7 +7,11 @@
<div class="right">
<@s.url var="bundlesUrl" nampespace="/osgi/admin" action="bundles" includeParams="none" />
+ <@s.url var="osgiShellUrl" namespace="/osgi/admin" action="shell" includeParams="none" />
+ <a href="${bundlesUrl}"><img src='<@s.url value="/static/search.gif"/>'</a>
<a href="${bundlesUrl}">Installed Bundles</a>
+ <a href="${bundlesUrl}"><img src='<@s.url value="/static/terminal.gif"/>'</a>
+ <a href="${osgiShellUrl}">OSGi Shell</a>
</div>
<@s.actionerror />
Modified: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundles.ftl
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundles.ftl?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundles.ftl (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/osgi/admin/viewBundles.ftl Wed Apr 8 19:25:30 2009
@@ -7,7 +7,11 @@
<body>
<div class="right">
+ <@s.url var="bundlesUrl" nampespace="/osgi/admin" action="bundles" includeParams="none" />
<@s.url var="osgiShellUrl" namespace="/osgi/admin" action="shell" includeParams="none" />
+ <a href="${bundlesUrl}"><img src='<@s.url value="/static/search.gif"/>'</a>
+ <a href="${bundlesUrl}">Installed Bundles</a>
+ <a href="${bundlesUrl}"><img src='<@s.url value="/static/terminal.gif"/>'</a>
<a href="${osgiShellUrl}">OSGi Shell</a>
</div>
<table class="properties" style="clear:both">
Modified: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/main.css
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/main.css?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/main.css (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/main.css Wed Apr 8 19:25:30 2009
@@ -38,4 +38,8 @@
table.properties th {
background-color: #C3D9FF;
+}
+
+img {
+ border-style: none;
}
\ No newline at end of file
Added: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/search.gif
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/search.gif?rev=763357&view=auto
==============================================================================
Binary file - no diff available.
Propchange: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/search.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/terminal.gif
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/terminal.gif?rev=763357&view=auto
==============================================================================
Binary file - no diff available.
Propchange: struts/sandbox/trunk/struts2-osgi-plugin/admin-bundle/src/main/resources/static/terminal.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/java/actions/osgi/HelloWorldAction.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/java/actions/osgi/HelloWorldAction.java?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/java/actions/osgi/HelloWorldAction.java (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/java/actions/osgi/HelloWorldAction.java Wed Apr 8 19:25:30 2009
@@ -22,6 +22,10 @@
this.message = message;
}
+ public String getSimpleMessage() {
+ return "Hello!!!";
+ }
+
public String toString() {
StringBuilder sb = new StringBuilder("{message:");
sb.append(message != null ? message.getText() : "null");
Modified: struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/resources/content/osgi/hello-convention.ftl
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/resources/content/osgi/hello-convention.ftl?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/resources/content/osgi/hello-convention.ftl (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/demo-bundle/src/main/resources/content/osgi/hello-convention.ftl Wed Apr 8 19:25:30 2009
@@ -5,6 +5,6 @@
<body>
This is an action mapped by the Convention plugin, using a FreeMarker result.
<br />
- Message from Action: ${message.text}
+ Message from Action: ${simpleMessage}
</body>
</html>
\ No newline at end of file
Modified: struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/DelegatingObjectFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/DelegatingObjectFactory.java?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/DelegatingObjectFactory.java (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/DelegatingObjectFactory.java Wed Apr 8 19:25:30 2009
@@ -58,7 +58,11 @@
}
public Object buildBean(String className, Map<String, Object> extraContext, boolean injectInternal) throws Exception {
- return delegateObjectFactory.buildBean(className, extraContext, injectInternal);
+ try {
+ return delegateObjectFactory.buildBean(className, extraContext, injectInternal);
+ } catch (Exception e) {
+ return bundleResourceLoader.loadClass(className).newInstance();
+ }
}
@Override
Modified: struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java Wed Apr 8 19:25:30 2009
@@ -73,6 +73,7 @@
private static Pattern versionPattern = Pattern.compile("([\\d])+[\\.-]");
private String startRunLevel;
private ServletContext servletContext;
+ private String logLevel;
protected void startFelix() {
//load properties from felix embedded file
@@ -103,7 +104,7 @@
//other properties
configProps.put(FelixConstants.SERVICE_URLHANDLERS_PROP, "false");
- configProps.put(FelixConstants.LOG_LEVEL_PROP, "4");
+ configProps.put(FelixConstants.LOG_LEVEL_PROP, logLevel);
configProps.put(FelixConstants.BUNDLE_CLASSPATH, ".");
configProps.put(FelixConstants.FRAMEWORK_BEGINNING_STARTLEVEL, startRunLevel);
@@ -135,7 +136,7 @@
addSpringOSGiSupport();
}
- private int addAutoStartBundles(Properties configProps) {
+ protected int addAutoStartBundles(Properties configProps) {
//starts system bundles in level 1
List<String> bundleJarsLevel1 = new ArrayList<String>();
bundleJarsLevel1.add(getJarUrl(ShellService.class));
@@ -147,7 +148,7 @@
//start app bundles in level 3
List<String> bundleJarsLevel3 = new ArrayList<String>();
- bundleJarsLevel2.addAll(getBundlesInDir("bundles"));
+ bundleJarsLevel3.addAll(getBundlesInDir("bundles"));
configProps.put(AutoActivator.AUTO_START_PROP + ".1", StringUtils.join(bundleJarsLevel1, " "));
@@ -158,7 +159,7 @@
return bundleJarsLevel1.size() + bundleJarsLevel2.size() + bundleJarsLevel3.size();
}
- private List<String> getBundlesInDir(String dir) {
+ protected List<String> getBundlesInDir(String dir) {
List<String> bundleJars = new ArrayList<String>();
try {
@@ -196,7 +197,7 @@
return bundleJars;
}
- private void addSpringOSGiSupport() {
+ protected void addSpringOSGiSupport() {
// see the javadoc for org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext for more details
// OsgiBundleXmlWebApplicationContext expects the the BundleContext to be set in the ServletContext under the attribute
// OsgiBundleXmlWebApplicationContext.BUNDLE_CONTEXT_ATTRIBUTE
@@ -216,14 +217,14 @@
}
}
- private String getJarUrl(Class clazz) {
+ protected String getJarUrl(Class clazz) {
ProtectionDomain protectionDomain = clazz.getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource();
URL loc = codeSource.getLocation();
return loc.toString();
}
- private void replaceSystemPackages(Properties properties) {
+ protected void replaceSystemPackages(Properties properties) {
//Felix has a way to load the config file and substitution expressions
//but the method does not have a way to specify the file (other than in an env variable)
@@ -237,7 +238,7 @@
/*
Find subpackages of the packages defined in the property file and export them
*/
- private void addExportedPackages(Properties strutsConfigProps, Properties configProps) {
+ protected void addExportedPackages(Properties strutsConfigProps, Properties configProps) {
String[] rootPackages = StringUtils.split((String) strutsConfigProps.get("scanning.package.includes"), ",");
ResourceFinder finder = new ResourceFinder(StringUtils.EMPTY);
List<String> exportedPackages = new ArrayList<String>();
@@ -273,7 +274,7 @@
/**
* Gets the version used to export the packages. it tries to get it from MANIFEST.MF, or the file name
*/
- private String getVersion(URL url) {
+ protected String getVersion(URL url) {
if ("jar".equals(url.getProtocol())) {
try {
JarFile jarFile = new JarFile(new File(URLUtil.normalizeToFileProtocol(url).toURI()));
@@ -300,7 +301,7 @@
/**
* Extracts numbers followed by "." or "-" from the string and joins them with "."
*/
- static String getVersionFromString(String str) {
+ protected static String getVersionFromString(String str) {
Matcher matcher = versionPattern.matcher(str);
List<String> parts = new ArrayList<String>();
while (matcher.find()) {
@@ -317,7 +318,7 @@
return StringUtils.join(parts, ".");
}
- private Properties getProperties(String fileName) {
+ protected Properties getProperties(String fileName) {
ResourceFinder finder = new ResourceFinder("");
try {
return finder.findProperties(fileName);
@@ -370,4 +371,9 @@
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
+
+ @Inject("struts.osgi.logLevel")
+ public void setLogLevel(String logLevel) {
+ this.logLevel = logLevel;
+ }
}
Modified: struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/SpringOsgiObjectFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/SpringOsgiObjectFactory.java?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/SpringOsgiObjectFactory.java (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/java/org/apache/struts2/osgi/SpringOsgiObjectFactory.java Wed Apr 8 19:25:30 2009
@@ -22,6 +22,7 @@
package org.apache.struts2.osgi;
import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.inject.Inject;
import org.osgi.framework.ServiceReference;
@@ -37,7 +38,16 @@
private BundleAccessor bundleAccessor;
public Object buildBean(String className, Map<String, Object> extraContext, boolean injectInternal) throws Exception {
- return containsBean(className) ? getBean(className) : super.buildBean(className, extraContext, injectInternal);
+ if (containsBean(className))
+ return getBean(className);
+ else {
+ Class clazz = ClassLoaderUtil.loadClass(className, SpringOsgiObjectFactory.class);
+ Object object = clazz.newInstance();
+ if (injectInternal)
+ injectInternalBeans(object);
+ return object;
+ }
+
}
public Object buildBean(Class clazz, Map<String, Object> extraContext) throws Exception {
@@ -45,7 +55,7 @@
}
public Class getClassInstance(String className) throws ClassNotFoundException {
- return containsBean(className) ? getBean(className).getClass() : super.getClassInstance(className);
+ return containsBean(className) ? getBean(className).getClass() : ClassLoaderUtil.loadClass(className, SpringOsgiObjectFactory.class);
}
protected Object getBean(String beanName) {
Modified: struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/resources/struts-plugin.xml
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/resources/struts-plugin.xml?rev=763357&r1=763356&r2=763357&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/resources/struts-plugin.xml (original)
+++ struts/sandbox/trunk/struts2-osgi-plugin/plugin/src/main/resources/struts-plugin.xml Wed Apr 8 19:25:30 2009
@@ -15,6 +15,9 @@
<constant name="struts.osgi.clearBundleCache" value="true" />
<constant name="struts.osgi.startRunLevel" value="3" />
+ <!--1 = error, 2 = warning, 3 = information, and 4 = debug -->
+ <constant name="struts.osgi.logLevel" value="1" />
+
<bean type="org.apache.struts2.osgi.BundleAccessor" class="org.apache.struts2.osgi.DefaultBundleAccessor" />
<bean type="org.apache.struts2.osgi.PackageLoader" class="org.apache.struts2.osgi.BundlePackageLoader" />
<bean name="osgi" type="com.opensymphony.xwork2.ObjectFactory" class="org.apache.struts2.osgi.DelegatingObjectFactory" />