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

Osgi updates for Grouper 5 #211

Draft
wants to merge 7 commits into
base: GROUPER_5_BRANCH
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
<groupId>edu.internet2.middleware.grouper</groupId>
<artifactId>grouper-parent</artifactId>
<version>5.0.0-SNAPSHOT</version>
<relativePath>../../../grouper-parent</relativePath>
<relativePath>../../grouper-parent</relativePath>
</parent>
<name>Grouper UI webapp</name>
<artifactId>grouper-ui-webapp</artifactId>

<name>Grouper webapp</name>
<artifactId>grouper-webapp</artifactId>
<packaging>war</packaging>

<dependencies>
Expand All @@ -38,12 +38,17 @@
<artifactId>grouper-ui</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grouper-ws</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>../../../grouper/conf</directory>
<directory>../../grouper/conf</directory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take this out

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I remember why this is here, but need to verify: ddls for some reason were missing from the classpath

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DDLs should be packaged in the grouper jar now

</resource>
</resources>
<plugins>
Expand All @@ -55,19 +60,30 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>../../../grouper-ui/webapp</directory>
<directory>../../grouper-ui/webapp</directory>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.27.v20200227</version>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven3-plugin</artifactId>
<version>1.10.9</version>
<configuration>
<webApp>
<contextPath>/grouper</contextPath>
</webApp>
<container>
<timeout>3600000</timeout>
</container>
<configuration>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.start.jvmargs>
-Xdebug
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005
-Xnoagent
-Djava.compiler=NONE
</cargo.start.jvmargs>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
Expand Down
14 changes: 14 additions & 0 deletions grouper-misc/webapp/src/test/resources/grouper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
grouper.osgi.enable = true

# directory of plugins, default to /opt/grouper/grouperWebapp/WEB-INF/grouperPlugins
# {valueType: "string", required: true, order: 1000}
grouper.osgi.jar.dir = /Users/jj/Documents/workspace/community/grouper-ext-auth/target

# directory of felix cache of plugins, default to /opt/grouper/grouperWebapp/WEB-INF/grouperFelixCache
# {valueType: "string", required: true, order: 2000}
grouper.felix.cache.rootdir = /tmp/grouperFelixCache

grouper.osgi.plugin.extauth.jar=grouper-authentication-plugin-0.0.1-SNAPSHOT.jar

# grouper.osgi.framework.system.packages.extra=javax.*,org.osgi.*,org.osgi,org.apache.commons.logging,edu.internet2.middleware.grouperClient.config,edu.internet2.middleware.grouper.app.externalSystem,org.w3c.dom.*
# grouper.osgi.framework.boot.delegation=javax.*,org.osgi.*,org.osgi,org.apache.commons.logging,edu.internet2.middleware.grouperClient.config,edu.internet2.middleware.grouper.app.externalSystem,org.w3c.dom.*
2 changes: 1 addition & 1 deletion grouper-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<module>../grouper-ui</module>
<module>../grouper-ws</module>
<module>../grouper-misc/grouper-installer</module>
<module>../grouper-misc/webapp/grouper-ui-webapp</module>
<module>../grouper-misc/webapp</module>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend removing this. This is the list of modules that are built and published at every release, and for which documentation is built. You can always build this manually, even if it's not in this list.

</modules>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package edu.internet2.middleware.grouper.plugins;

import edu.internet2.middleware.grouper.app.externalSystem.GrouperExternalSystem;
import edu.internet2.middleware.grouper.cfg.GrouperConfig;
import edu.internet2.middleware.grouper.cfg.GrouperHibernateConfig;
import edu.internet2.middleware.grouper.util.GrouperUtil;
import edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
Expand All @@ -16,6 +17,7 @@
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -30,6 +32,8 @@
* @author jj
*/
public class FrameworkStarter {
private final static Log LOG = GrouperUtil.getLog(FrameworkStarter.class);

private final static FrameworkStarter frameworkStarter = new FrameworkStarter();

private Framework framework;
Expand All @@ -51,8 +55,15 @@ public void start() {
// if it caches modules, they might not ever get reloaded
configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);

//TODO: maybe make this more dynamic. currently we're very opinionated on what we export
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, GrouperConfig.retrieveConfig().propertyValueString("grouper.osgi.framework.system.packages.extra","javax.servlet,javax.servlet.http"));
Set<String> frameworkSystemPackagesExtra = new HashSet<>();
// TODO: add any needed system packages here
if (null != GrouperConfig.retrieveConfig().propertyValueString("grouper.osgi.framework.system.packages.extra")) {
LOG.warn("You are setting a value for `grouper.osgi.framework.system.packages.extra`. This generally not needed and should not be used unless there is a good reason to do so");
scalding marked this conversation as resolved.
Show resolved Hide resolved
frameworkSystemPackagesExtra.addAll(Arrays.asList(GrouperConfig.retrieveConfig().propertyValueString("grouper.osgi.framework.system.packages.extra", "").split(",")));
}
if (!frameworkSystemPackagesExtra.isEmpty()) {
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, String.join(",", frameworkSystemPackagesExtra));
}

try {
// set up cachedir
Expand All @@ -65,18 +76,18 @@ public void start() {

// usually, this is a bad idea, but we have several classes that must be loaded from the framework classpath to work,
// e.g., logging, configuration
String packagesForBootDelegationString;
Set<String> packagesForBootDelegation = new HashSet<>();
if (null != GrouperConfig.retrieveConfig().propertyValueString("grouper.osgi.framework.boot.delegation")) {
packagesForBootDelegationString = GrouperConfig.retrieveConfig().propertyValueString("grouper.osgi.framework.boot.delegation");
LOG.warn("You are setting a value for `grouper.osgi.framework.boot.delegation`. This is generally not needed adn should not be used unless there is a good reason to do so");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

packagesForBootDelegation.addAll(Arrays.asList(GrouperConfig.retrieveConfig().propertyValueString("grouper.osgi.framework.boot.delegation").split(",")));
} else {
Set<String> packagesForBootDelegation = new HashSet<>();
packagesForBootDelegation.add(LogFactory.class.getPackage().getName());
packagesForBootDelegation.add(ConfigPropertiesCascadeBase.class.getPackage().getName());
// TODO: why oh why... need to fix this
packagesForBootDelegation.add(GrouperExternalSystem.class.getPackage().getName());
packagesForBootDelegationString = String.join(",", packagesForBootDelegation);
packagesForBootDelegation.add("org.osgi.*");
packagesForBootDelegation.add("javax.*");
packagesForBootDelegation.add("org.apache.commons.logging");
packagesForBootDelegation.add("edu.internet2.middleware.grouper.*");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to check this, but could cause a problem if a plugin ends up in the classpath (e.g. class clash)

packagesForBootDelegation.add("edu.internet2.middleware.grouperClient.*");
}
configMap.put(Constants.FRAMEWORK_BOOTDELEGATION, packagesForBootDelegationString);
configMap.put(Constants.FRAMEWORK_BOOTDELEGATION, String.join(",", packagesForBootDelegation));

try {
FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next();
Expand Down