import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;
+import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
* Wrapper around a Jackrabbit repository which allows to configure it in Spring
* and expose it as a {@link Repository}.
*/
* Wrapper around a Jackrabbit repository which allows to configure it in Spring
* and expose it as a {@link Repository}.
*/
-public class JackrabbitContainer extends JackrabbitWrapper {
+public class JackrabbitContainer extends JackrabbitWrapper implements
+ ResourceLoaderAware {
private Log log = LogFactory.getLog(JackrabbitContainer.class);
// remote
private Log log = LogFactory.getLog(JackrabbitContainer.class);
// remote
// local
private Resource configuration;
private Resource variables;
// local
private Resource configuration;
private Resource variables;
+ private ResourceLoader resourceLoader;
// data model
/** Node type definitions in CND format */
// data model
/** Node type definitions in CND format */
Session session = null;
try {
Session session = null;
try {
+ if (remoteSystemCredentials == null)
+ session = login();
+ else
+ session = login(remoteSystemCredentials);
// register namespaces
if (namespaces.size() > 0) {
NamespaceHelper namespaceHelper = new NamespaceHelper(session);
// register namespaces
if (namespaces.size() > 0) {
NamespaceHelper namespaceHelper = new NamespaceHelper(session);
}
} else {
url = getClass().getClassLoader().getResource(resUrl);
}
} else {
url = getClass().getClassLoader().getResource(resUrl);
+ // if (url == null)
+ // url = Thread.currentThread()
+ // .getContextClassLoader()
+ // .getResource(resUrl);
- if (url == null)
- throw new ArgeoException("No " + resUrl
- + " in the classpath,"
- + " make sure the containing"
- + " package is visible.");
-
} else {
url = new URL(resUrl);
}
} else {
url = new URL(resUrl);
}
Reader reader = null;
try {
Reader reader = null;
try {
- reader = new InputStreamReader(url.openStream());
+ if (url != null) {
+ in = url.openStream();
+ } else if (resourceLoader != null) {
+ Resource res = resourceLoader.getResource(resUrl);
+ in = res.getInputStream();
+ url = res.getURL();
+ } else {
+ throw new ArgeoException("No " + resUrl
+ + " in the classpath,"
+ + " make sure the containing"
+ + " package is visible.");
+ }
+
+ reader = new InputStreamReader(in);
// actually imports the CND
CndImporter.registerNodeTypes(reader, session, true);
// actually imports the CND
CndImporter.registerNodeTypes(reader, session, true);
session.getWorkspace().getVersionManager()
.checkin(dataModel.getPath());
} finally {
session.getWorkspace().getVersionManager()
.checkin(dataModel.getPath());
} finally {
+ IOUtils.closeQuietly(in);
IOUtils.closeQuietly(reader);
}
IOUtils.closeQuietly(reader);
}
this.forceCndImport = forceCndUpdate;
}
this.forceCndImport = forceCndUpdate;
}
+ public void setResourceLoader(ResourceLoader resourceLoader) {
+ this.resourceLoader = resourceLoader;
+ }
+
/** Wraps access to the repository, making sure it is available. */
protected Repository getRepository() {
if (repository == null) {
/** Wraps access to the repository, making sure it is available. */
protected Repository getRepository() {
if (repository == null) {
- throw new ArgeoException(
- "No repository initialized."
- + " Was the init() method called?"
- + " The dispose() method should also be called on shutdown.");
+ throw new ArgeoException("No repository initialized."
+ + " Was the init() method called?"
+ + " The destroy() method should also"
+ + " be called on shutdown.");