Skip to content

Commit

Permalink
Add Mongo Persistence
Browse files Browse the repository at this point in the history
Signed-off-by: Guido Grune <g.grune@datainmotion.com>
  • Loading branch information
gg-dim committed Feb 2, 2024
1 parent 8392d29 commit c2bce15
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions org.gecko.emf.mongo/component.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Export-Package: \
org.gecko.emf.mongo.model,\
org.gecko.emf.mongo.model.util,\
org.gecko.emf.mongo,\
org.gecko.emf.mongo.resource,\
org.gecko.emf.mongo.annotations,\
org.gecko.emf.mongo.converter,\
org.gecko.emf.mongo.util,\
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) 2012 - 2024 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Data In Motion - initial API and implementation
*/
package org.gecko.emf.mongo.resource;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
import org.gecko.emf.osgi.constants.EMFNamespaces;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;

/**
*
* @author grune
* @since Jan 23, 2024
*
* enabled = false da es eine weiter Implementierung im codec mongo_generator branch gibt
*/
@Component(enabled = false , service = Resource.Factory.class, property = { EMFNamespaces.EMF_CONFIGURATOR_NAME + "=myMongo",
EMFNamespaces.EMF_MODEL_PROTOCOL + "=mongodb" })
public class MongoPersistenceResourceFactoryImpl extends ResourceFactoryImpl {

@Activate
public void activate() {
}

@Deactivate
public void deactivate() {
}

@Override
public Resource createResource(URI uri) {
return new MongoPersistenceResourceImpl(uri);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2012 - 2024 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Data In Motion - initial API and implementation
*/
package org.gecko.emf.mongo.resource;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
import org.gecko.emf.mongo.streams.MongoInputStream;
import org.gecko.emf.mongo.streams.MongoOutputStream;

/**
*
* @author grune
* @since Jan 23, 2024
*/
final class MongoPersistenceResourceImpl extends ResourceImpl {
/**
* Creates a new instance.
* @param uri
*/
MongoPersistenceResourceImpl(URI uri) {
super(uri);
}

@Override
protected void doSave(OutputStream outputStream, Map<?, ?> options) throws IOException {
((MongoOutputStream) outputStream).saveResource(this);
}

@Override
protected void doLoad(InputStream inputStream, Map<?, ?> options) throws IOException {
((MongoInputStream) inputStream).loadResource(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@org.osgi.annotation.versioning.Version("1.0.0")
package org.gecko.emf.mongo.resource;

0 comments on commit c2bce15

Please sign in to comment.