http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jgroups/osgi.bundle ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jgroups/osgi.bundle b/extensions/entitystore-jgroups/osgi.bundle deleted file mode 100644 index 30d169e..0000000 --- a/extensions/entitystore-jgroups/osgi.bundle +++ /dev/null @@ -1,59 +0,0 @@ -Bundle-Activator: - -Private-Package: - -Ignore-Package: bsh, \ - com_cenqua_clover, \ - junit.framework, \ - junit.textui, \ - org.jgroups.tests, \ - org.jgroups.debug, \ - org.bouncycastle.jce.provider - -Import-Package: javax.crypto, \ - javax.crypto.spec, \ - javax.jms, \ - javax.management, \ - javax.naming, \ - javax.net, \ - javax.net.ssl, \ - javax.xml.parsers, \ - org.apache.commons.logging, \ - org.jgroups, \ - org.jgroups.blocks, \ - org.qi4j.api, \ - org.qi4j.api.composite, \ - org.qi4j.api.concern, \ - org.qi4j.api.entity, \ - org.qi4j.api.injection.scope, \ - org.qi4j.api.io, \ - org.qi4j.api.mixin, \ - org.qi4j.api.service, \ - org.qi4j.api.structure,\ - org.qi4j.entitystore.map, \ - org.qi4j.library.locking, \ - org.qi4j.spi.composite, \ - org.qi4j.spi.entity, \ - org.qi4j.spi.entity.helpers, \ - org.qi4j.spi.entitystore, \ - org.qi4j.spi.serialization, \ - org.qi4j.spi.service, \ - org.w3c.dom - -Export-Package: org.qi4j.entitystore.jgroups, \ - org.jgroups, \ - org.jgroups.blocks, \ - org.jgroups.conf, \ - org.jgroups.jmx, \ - org.jgroups.mux, \ - org.jgroups.persistence, \ - org.jgroups.stack, \ - org.jgroups.util, \ - org.jgroups.auth, \ - org.jgroups.protocols, \ - org.jgroups.protocols.pbcast - -Embed-Dependency: org.jgroups;scope=compile|runtime, \ - org.jgroups.*;scope=compile|runtime - -Embed-Transitive: true
http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jgroups/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jgroups/pom.xml b/extensions/entitystore-jgroups/pom.xml deleted file mode 100644 index 8e4c22a..0000000 --- a/extensions/entitystore-jgroups/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.qi4j.sandbox</groupId> - <artifactId>qi4j-sandbox-extensions</artifactId> - <version>0-SNAPSHOT</version> - </parent> - <groupId>org.qi4j.extension</groupId> - <artifactId>qi4j-entitystore-jgroups</artifactId> - <name>Qi4j Extension - EntityStore - JGroups</name> - <packaging>jar</packaging> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <argLine>-Djava.net.preferIPv4Stack=true</argLine> - </configuration> - </plugin> - </plugins> - </build> - <dependencies> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.spi</artifactId> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.testsupport</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.runtime</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.qi4j.library</groupId> - <artifactId>org.qi4j.library.locking</artifactId> - </dependency> - <dependency> - <groupId>jgroups</groupId> - <artifactId>jgroups</artifactId> - <version>2.6.2</version> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.1</version> - </dependency> - </dependencies> - <repositories> - <repository> - <id>jboss-repository</id> - <url>http://repository.jboss.org/maven2</url> - </repository> - </repositories> -</project> http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jgroups/src/main/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jgroups/src/main/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreMixin.java b/extensions/entitystore-jgroups/src/main/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreMixin.java deleted file mode 100644 index 6997f0d..0000000 --- a/extensions/entitystore-jgroups/src/main/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreMixin.java +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright 2008 Rickard Ãberg. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.entitystore.jgroups; - -import org.jgroups.JChannel; -import org.jgroups.blocks.ReplicatedHashMap; -import org.qi4j.api.entity.EntityReference; -import org.qi4j.io.Input; -import org.qi4j.io.Output; -import org.qi4j.io.Receiver; -import org.qi4j.io.Sender; -import org.qi4j.spi.entitystore.EntityNotFoundException; -import org.qi4j.spi.entitystore.EntityStoreException; - -import java.io.*; -import org.qi4j.api.entity.EntityDescriptor; -import org.qi4j.api.service.ServiceActivation; -import org.qi4j.spi.entitystore.helpers.MapEntityStore; - -/** - * JGroups implementation of EntityStore - */ -public class JGroupsEntityStoreMixin - implements ServiceActivation, MapEntityStore -{ - private JChannel channel; - private ReplicatedHashMap<String, String> replicatedMap; - - public void activateService() throws Exception - { - channel = new JChannel(); - channel.connect( "entitystore" ); - replicatedMap = new ReplicatedHashMap<String, String>( channel, false ); - replicatedMap.setBlockingUpdates( true ); - } - - public void passivateService() throws Exception - { - channel.close(); - } - - public Reader get( EntityReference entityReference ) - throws EntityStoreException - { - try - { - String data = replicatedMap.get( entityReference.identity() ); - if (data == null) - { - throw new EntityNotFoundException( entityReference ); - } - return new StringReader( data ); - } - catch (RuntimeException e) - { - throw new EntityStoreException( e ); - } - } - - public Input<Reader, IOException> entityStates() - { - return new Input<Reader, IOException>() - { - public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output ) - throws IOException, ReceiverThrowableType - { - output.receiveFrom( - new Sender<Reader, IOException>() - { - public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ReceiverThrowableType> receiver ) - throws ReceiverThrowableType, IOException - { - for( String json : replicatedMap.values() ) - { - receiver.receive( new StringReader( json ) ); - } - } - } - ); - } - }; - } - - public void applyChanges( MapChanges changes ) throws IOException - { - try - { - changes.visitMap( new MapChanger() - { - public Writer newEntity( final EntityReference ref, EntityDescriptor entityDescriptor ) throws IOException - { - return new StringWriter( 1000 ) - { - @Override - public void close() throws IOException - { - super.close(); - String value = toString(); - String key = ref.identity(); - replicatedMap.put( key, value ); - } - }; - } - - public Writer updateEntity( final EntityReference ref, EntityDescriptor entityDescriptor ) throws IOException - { - return new StringWriter( 1000 ) - { - @Override - public void close() throws IOException - { - super.close(); - String value = toString(); - String key = ref.identity(); - replicatedMap.put( key, value ); - } - }; - } - - public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor ) throws EntityNotFoundException - { - replicatedMap.remove( ref.identity() ); - } - } ); - } - catch (RuntimeException e) - { - IOException exception = new IOException(); - exception.initCause( e ); - throw exception; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jgroups/src/main/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreService.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jgroups/src/main/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreService.java b/extensions/entitystore-jgroups/src/main/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreService.java deleted file mode 100644 index bf82584..0000000 --- a/extensions/entitystore-jgroups/src/main/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2008 Rickard Ãberg. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.entitystore.jgroups; - -import org.qi4j.api.concern.Concerns; -import org.qi4j.api.mixin.Mixins; -import org.qi4j.api.service.ServiceActivation; -import org.qi4j.library.locking.LockingAbstractComposite; -import org.qi4j.spi.entitystore.ConcurrentModificationCheckConcern; -import org.qi4j.spi.entitystore.EntityStore; -import org.qi4j.spi.entitystore.StateChangeNotificationConcern; -import org.qi4j.spi.entitystore.helpers.MapEntityStoreMixin; - -/** - * EntityStore service backed by JGroups store. - */ - -@Concerns({ StateChangeNotificationConcern.class, ConcurrentModificationCheckConcern.class}) -@Mixins({ MapEntityStoreMixin.class, JGroupsEntityStoreMixin.class}) -public interface JGroupsEntityStoreService - extends EntityStore, ServiceActivation, LockingAbstractComposite - -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jgroups/src/test/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreTest.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jgroups/src/test/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreTest.java b/extensions/entitystore-jgroups/src/test/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreTest.java deleted file mode 100644 index d4f3423..0000000 --- a/extensions/entitystore-jgroups/src/test/java/org/qi4j/entitystore/jgroups/JGroupsEntityStoreTest.java +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright 2008 Rickard Ãberg. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.qi4j.entitystore.jgroups; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import org.junit.Test; -import org.junit.Ignore; -import org.qi4j.api.common.Optional; -import org.qi4j.api.entity.EntityBuilder; -import org.qi4j.api.entity.EntityComposite; -import org.qi4j.api.association.Association; -import org.qi4j.api.association.ManyAssociation; -import org.qi4j.api.property.Immutable; -import org.qi4j.api.property.Property; -import org.qi4j.api.unitofwork.NoSuchEntityException; -import org.qi4j.api.unitofwork.UnitOfWork; -import org.qi4j.api.unitofwork.UnitOfWorkCompletionException; -import org.qi4j.api.value.ValueBuilder; -import org.qi4j.api.value.ValueComposite; -import org.qi4j.api.value.ValueSerialization; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.bootstrap.SingletonAssembler; -import org.qi4j.spi.uuid.UuidIdentityGeneratorService; -import org.qi4j.test.AbstractQi4jTest; -import org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService; - -/** - * Test of JGroups EntityStore backend. - */ -public class JGroupsEntityStoreTest - extends AbstractQi4jTest -{ - public void assemble( ModuleAssembly module ) throws AssemblyException - { - module.services( UuidIdentityGeneratorService.class ); - module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON ); - module.entities( TestEntity.class ); - module.values( TestValue.class ); - module.services( JGroupsEntityStoreService.class ); - } - - @Test - @Ignore - public void whenNewEntityThenFindInReplica() - throws Exception - { - // Create first app - SingletonAssembler app1 = new SingletonAssembler() - { - public void assemble( ModuleAssembly module ) throws AssemblyException - { - module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON ); - module.services( JGroupsEntityStoreService.class, UuidIdentityGeneratorService.class ).instantiateOnStartup(); - module.entities( TestEntity.class ); - } - }; - - // Create second app - SingletonAssembler app2 = new SingletonAssembler() - { - public void assemble( ModuleAssembly module ) throws AssemblyException - { - module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON ); - module.services( JGroupsEntityStoreService.class, UuidIdentityGeneratorService.class ).instantiateOnStartup(); - module.entities( TestEntity.class ); - } - }; - - // Create entity in app 1 - System.out.println( "Create entity" ); - UnitOfWork app1Unit = app1.module().newUnitOfWork(); - EntityBuilder<TestEntity> builder = app1Unit.newEntityBuilder( TestEntity.class ); - TestEntity instance = builder.instance(); - instance.name().set( "Foo" ); - instance = builder.newInstance(); - app1Unit.complete(); - -// Thread.sleep( 5000 ); - - // Find entity in app 2 - System.out.println( "Find entity" ); - UnitOfWork app2Unit = app2.module().newUnitOfWork(); - instance = app2Unit.get( instance ); - - System.out.println( instance.name() ); - app2Unit.discard(); - - } - - @Test - @Ignore - public void whenNewEntityThenCanFindEntity() - throws Exception - { - try - { - UnitOfWork unitOfWork = module.newUnitOfWork(); - try - { - TestEntity instance = createEntity( unitOfWork ); - unitOfWork.complete(); - - // Find entity - unitOfWork = module.newUnitOfWork(); - instance = unitOfWork.get( instance ); - - // Check state - assertThat( "property has correct value", instance.name().get(), equalTo( "Test" ) ); - assertThat( "property has correct value", instance.unsetName().get(), equalTo( null ) ); - assertThat( "association has correct value", instance.association().get(), equalTo( instance ) ); - assertThat( "manyAssociation has correct value", instance.manyAssociation().iterator().next(), equalTo( instance ) ); - unitOfWork.discard(); - } - catch( UnitOfWorkCompletionException e ) - { - unitOfWork.discard(); - throw e; - } - catch( NoSuchEntityException e ) - { - unitOfWork.discard(); - throw e; - } - catch( RuntimeException e ) - { - unitOfWork.discard(); - throw e; - } - - } - catch( Exception e ) - { - e.printStackTrace(); - } - } - - @Test - @Ignore - public void whenRemovedEntityThenCannotFindEntity() - throws Exception - { - UnitOfWork unitOfWork = module.newUnitOfWork(); - try - { - TestEntity newInstance = createEntity( unitOfWork ); - String identity = newInstance.identity().get(); - unitOfWork.complete(); - - // Remove entity - unitOfWork = module.newUnitOfWork(); - TestEntity instance = unitOfWork.get( newInstance ); - unitOfWork.remove( instance ); - unitOfWork.complete(); - - // Find entity - unitOfWork = module.newUnitOfWork(); - try - { - instance = unitOfWork.get( TestEntity.class, identity ); - fail( "Should not be able to find entity" ); - } - catch( NoSuchEntityException e ) - { - // Ok! - } - unitOfWork.discard(); - } - catch( UnitOfWorkCompletionException e ) - { - unitOfWork.discard(); - throw e; - } - catch( NoSuchEntityException e ) - { - unitOfWork.discard(); - throw e; - } - catch( RuntimeException e ) - { - unitOfWork.discard(); - throw e; - } - } - - protected TestEntity createEntity( UnitOfWork unitOfWork ) - throws UnitOfWorkCompletionException - { - // Create entity - EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class ); - TestEntity instance = builder.newInstance(); - String id = instance.identity().get(); - - instance.name().set( "Test" ); - instance.association().set( instance ); - - ValueBuilder<TestValue> valueBuilder = module.newValueBuilder( TestValue.class ); - TestValue state = valueBuilder.prototype(); - state.someValue().set( "Foo" ); - state.otherValue().set( 5 ); - - TestValue value = valueBuilder.newInstance(); - - instance.valueProperty().set( value ); - instance.manyAssociation().add( instance ); - - return instance; - } - - public interface TestEntity - extends EntityComposite - { - @Optional Property<String> name(); - - @Optional Property<String> unsetName(); - - @Optional Property<TestValue> valueProperty(); - - @Optional Association<TestEntity> association(); - - @Optional Association<TestEntity> unsetAssociation(); - - ManyAssociation<TestEntity> manyAssociation(); - } - - public interface TestValue extends ValueComposite - { - @Immutable Property<String> someValue(); - - @Immutable Property<Integer> otherValue(); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/.gitignore ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/.gitignore b/extensions/entitystore-jndi/.gitignore deleted file mode 100644 index 2f7896d..0000000 --- a/extensions/entitystore-jndi/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target/ http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/osgi.bundle ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/osgi.bundle b/extensions/entitystore-jndi/osgi.bundle deleted file mode 100644 index ddb1f77..0000000 --- a/extensions/entitystore-jndi/osgi.bundle +++ /dev/null @@ -1,30 +0,0 @@ -Import-Package:\ - javax.naming, \ - javax.naming.directory, \ - javax.naming.ldap, \ - org.qi4j.api.common, \ - org.qi4j.api.concern, \ - org.qi4j.api.configuration, \ - org.qi4j.api.entity, \ - org.qi4j.api.injection.scope, \ - org.qi4j.api.io, \ - org.qi4j.api.mixin, \ - org.qi4j.api.property, \ - org.qi4j.api.service, \ - org.qi4j.api.structure, \ - org.qi4j.api.usecase, \ - org.qi4j.bootstrap, \ - org.qi4j.entitystore.memory, \ - org.qi4j.library.locking, \ - org.qi4j.spi.entity, \ - org.qi4j.spi.entity.association, \ - org.qi4j.spi.entity.helpers, \ - org.qi4j.spi.entitystore, \ - org.qi4j.spi.property, \ - org.qi4j.spi.structure, \ - org.qi4j.spi.unitofwork, \ - org.qi4j.spi.uuid - -Export-Package:\ - org.qi4j.entitystore.jndi - http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/pom.xml b/extensions/entitystore-jndi/pom.xml deleted file mode 100644 index c4ce324..0000000 --- a/extensions/entitystore-jndi/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.qi4j.sandbox</groupId> - <artifactId>qi4j-sandbox-extensions</artifactId> - <version>0-SNAPSHOT</version> - </parent> - <groupId>org.qi4j.extension</groupId> - <artifactId>qi4j-entitystore-jndi</artifactId> - <name>Qi4j Extension - EntityStore - JNDI</name> - - <dependencies> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.api</artifactId> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.spi</artifactId> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.bootstrap</artifactId> - </dependency> - <dependency> - <groupId>org.qi4j.library</groupId> - <artifactId>org.qi4j.library.locking</artifactId> - </dependency> - - <!-- Tests --> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.testsupport</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.runtime</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.qi4j.library</groupId> - <artifactId>org.qi4j.library.ldap-server</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiConfiguration.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiConfiguration.java b/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiConfiguration.java deleted file mode 100644 index e3bd659..0000000 --- a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiConfiguration.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright 2008 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.common.Optional; -import org.qi4j.api.common.UseDefaults; -import org.qi4j.api.configuration.ConfigurationComposite; -import org.qi4j.api.property.Property; - -/** - * Configuration for the JNDI EntityStore. - * <p> - * Many of the Property instances are passed on to the <code>javax.naming.InitialContext</code> as is, and the javadoc - * below mirrors the meaning found for the constants in the <code>javax.naming.Context</code> interface. - * </p> - */ -public interface JndiConfiguration extends ConfigurationComposite -{ - - /** - * If set to read-only mode, then no creation and no updates of the EntityStore will be allowed. - * - * @return if true, then don't allow updates of the underlying store. Such operations will throw a - * ReadOnlyEntityStoreException. - */ - @UseDefaults Property<Boolean> readOnly(); - - /** - * Instance version property. - * - * If the EntityStore is NOT readonly, each entry must have an attribute to store the instance version. This - * Property names that attribute available in all entries. - * - * If not specified, the atttribute used will be "instanceVersion". - * - * @return The name of the attribute where to store the instance version number. - */ - @Optional Property<String> versionAttribute(); - - /** - * Last modified property. - * If the EntityStore is NOT readonly, each entry must have an attribute to store the last modified date. - * This property names that attributes in all entries. - * - * If not specified, the attribute used will be "lastModifiedDate". - * - * @return The name of the attribute where to store the last modified date. - */ - @Optional Property<String> lastModifiedDateAttribute(); - - /** - * QualifiedType attribute. - * - * If the EntityStore is going to support the Iterable interface, it must store the qualifiedType in an - * attribute in the entry. This is also required for non-readOnly stores. - * - * @return The name of the attribute where to store the qualifiedType. - */ - @Optional Property<String> qualifiedTypeAttribute(); - - /** - * Whether Turbo Mode for serialization should be used or not. - * - * @return Whether turbo mode is enabled or not. - */ - @UseDefaults Property<Boolean> turboMode(); - - /** - * The Distinguished Name of the base. - * All creation and retrieval will occur in this directory. - * - * @return The property of the DN to the directory of operation. - */ - Property<String> baseDN(); - - /** - * This will provide the name of the attribute where the binary blob of the properties will be stored. - * <p> - * If there is no attribute name provided, each property will be stored in its own attribute, of the same - * name as the property itself. - * </p> - * <p> - * Note: Associations are always stored in attributes with the same name as the attribute itself. It doesn't - * allow for aggregated/collapsing of all into a single attribute as is possible for property data. - * </p> - * - * @return The property containing the attribute name, or empty if property collapsing should not occur. - */ - @Optional Property<String> propertyAttribute(); - - - /** - * The attribute to use for storing the identity in an entry. - * - * <p> - * If there is no attribute name provided, then use "uid" as the identity attribute in the entry. - * </p> - * - * @return - */ - @UseDefaults Property<String> identityAttribute(); - - /** - * Property for specifying the authoritativeness of the service requested. - * <p> - * If the value of the property is the string "true", it means that the access is to the most authoritative - * source (i.e. bypass any cache or replicas). If the value is anything else, the source need not be (but may be) - * authoritative. If unspecified, the value defaults to "false". - * </p> - * - * @return The property containing the string "true" or "false", whether the source is authorative or not. - */ - @Optional Property<String> authorative(); - - /** - * Property for specifying the batch size to use when returning data via the service's protocol. - * <p> - * This is a hint to the provider to return the results of operations in batches of the specified size, so the - * provider can optimize its performance and usage of resources. The value of the property is the string - * representation of an integer. If unspecified, the batch size is determined by the service provider. - * - * @return The property that contains the batch size. - */ - @Optional Property<String> batchSize(); - - /** - * Property for specifying the list of control factories to use. - * <p> - * The value of the property should be a colon-separated list of the fully qualified class names of factory - * classes that will create a control given another control. - * </p> - * - * @return The property that possibly contains the control factory(ies) class names. - */ - @Optional Property<String> controlFactories(); - - /** - * Property for specifying the DNS host and domain names to use for the JNDI URL context (for example, - * "dns://somehost/wiz.com"). - * - * <p> - * This property may be specified in the environment, an applet parameter, a system property, or a resource file. - * If it is not specified in any of these sources and the program attempts to use a JNDI URL containing a DNS - * name, a ConfigurationException will be thrown. - * </p> - * - * @return - */ - @Optional Property<String> dnsUrl(); - - /** - * Property for specifying the initial context factory to use. - * <p> - * The value of the property should be the fully qualified class name of the factory class that will create an - * initial context. If it is not specified in any of these sources, NoInitialContextException is thrown when an - * initial context is required to complete an operation. - * </p> - * - * @return - */ - @Optional Property<String> initialContextFactory(); - - /** - * Property for specifying the preferred language to use with the service. - * - * <p> - * The value of the property is a colon-separated list of language tags as defined in RFC 1766. If this property - * is unspecified, the language preference is determined by the service provider. - * </p> - * - * @return - */ - @Optional Property<String> language(); - - /** - * Property for specifying the list of object factories to use. - * <p> - * The value of the property should be a colon-separated list of the fully qualified class names of factory classes - * that will create an object given information about the object. - * </p> - * - * @return - */ - @Optional Property<String> objectFactories(); - - /** - * The URL string to connect to the LDAP server. - * - * property for specifying configuration information for the service provider to use. The value of the property - * should contain a URL string (e.g. "ldap://somehost:389"). It may also contain connect arguments as query - * arguments in the URL. - * - * @return The connection string to use to connect. - */ - Property<String> providerUrl(); - - /** - * A property to define how referrals should be dealt with. - * <p> - * The value of the property is one of the following strings: - * <code><pre> - * "follow" follow referrals automatically - * "ignore" ignore referrals - * "throw" throw ReferralException when a referral is encountered. - * If this property is not specified, the default is determined by the provider. - */ - @Optional Property<String> referral(); - - /** - * What type of authentication should be used. - * <p> - * Its value is one of the following strings: "none", "simple", "strong". If this property is unspecified, the - * behaviour is determined by the service provider. - * </p> - * - * @return - */ - @Optional Property<String> securityAuthentication(); - - /** - * The Principal passworf to log into the LDAP server. - * - * <p> - * The value of the property depends on the authentication scheme. For example, it could be a hashed password, - * clear-text password, key, certificate, and so on. - * </p> - * - * @return The password to use to log in. - */ - Property<String> securityCredentials(); - - /** - * The Principal Name to log into the LDAP server. - * - * @return The username to use to log in. - */ - Property<String> securityPrincipal(); - - /** - * The Security protocol, if any, to be used. - * - * @return The protocol that should be used, or null if defined by the provider. - */ - @Optional Property<String> securityProtocol(); - - /** - * Property for specifying the list of state factories to use. - * <p> - * The value of the property should be a colon-separated list of the fully qualified class names of state factory - * classes that will be used to get an object's state given the object itself. - * </p> - * - * @return - */ - @Optional Property<String> stateFactories(); - - /** - * Property for specifying the list of package prefixes to use when loading in URL context factories. - * <p> - * The value of the property should be a colon-separated list of package prefixes for the class name of the - * factory class that will create a URL context factory. - * The prefix com.sun.jndi.url is always appended to the possibly empty list of package prefixes. - * </p> - * - * @return - */ - @Optional Property<String> urlPkgPrefixes(); - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityState.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityState.java b/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityState.java deleted file mode 100644 index 036995e..0000000 --- a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityState.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2009 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.entity.EntityDescriptor; -import org.qi4j.spi.entity.EntityState; -import org.qi4j.spi.entity.EntityStatus; -import org.qi4j.api.entity.EntityReference; -import org.qi4j.spi.entity.ManyAssociationState; -import org.qi4j.api.common.QualifiedName; -import java.util.Map; -import java.util.List; -import java.util.HashMap; - -public class JndiEntityState - implements EntityState -{ - private JndiUow unitOfWork; - protected EntityStatus status; - protected String version; - protected long lastModified; - private final EntityReference identity; - - private final EntityDescriptor entityDescriptor; - protected final Map<QualifiedName, Object> properties; - protected final Map<QualifiedName, EntityReference> associations; - protected final Map<QualifiedName, List<EntityReference>> manyAssociations; - - public JndiEntityState( JndiUow unitOfWork, EntityReference identity, EntityDescriptor entityDescriptor) - { - this( unitOfWork, "", - System.currentTimeMillis(), - identity, - EntityStatus.NEW, - entityDescriptor, - new HashMap<QualifiedName, Object>(), - new HashMap<QualifiedName, EntityReference>(), - new HashMap<QualifiedName, List<EntityReference>>() ); - } - - public JndiEntityState( JndiUow unitOfWork, - String version, - long lastModified, - EntityReference identity, - EntityStatus status, - EntityDescriptor entityDescriptor, - Map<QualifiedName, Object> properties, - Map<QualifiedName, EntityReference> associations, - Map<QualifiedName, List<EntityReference>> manyAssociations ) - { - this.unitOfWork = unitOfWork; - this.version = version; - this.lastModified = lastModified; - this.identity = identity; - this.status = status; - this.entityDescriptor = entityDescriptor; - this.properties = properties; - this.associations = associations; - this.manyAssociations = manyAssociations; - } - - - public EntityReference identity() - { - return identity; - } - - public String version() - { - return version; - } - - public long lastModified() - { - return lastModified; - } - - public void remove() - { - } - - public EntityStatus status() - { - return status; - } - - public boolean isAssignableTo( Class<?> type ) - { - return false; - } - - public EntityDescriptor entityDescriptor() - { - return entityDescriptor; - } - - public Object propertyValueOf( QualifiedName stateName ) - { - return properties.get( stateName ); - } - - public void setPropertyValue( QualifiedName stateName, Object json ) - { - properties.put( stateName, json ); - } - - public EntityReference associationValueOf( QualifiedName stateName ) - { - return associations.get( stateName ); - } - - public void setAssociationValue( QualifiedName stateName, EntityReference newEntity ) - { - associations.put( stateName, newEntity ); - } - - public ManyAssociationState manyAssociationValueOf( QualifiedName stateName ) - { - return null; - } - - public void refresh() - { - } - - public void hasBeenApplied() - { - status = EntityStatus.LOADED; - version = unitOfWork.identity(); - } - - @Override - public String toString() - { - return identity + "(" + - properties.size() + " properties, " + - associations.size() + " associations, " + - manyAssociations.size() + " many-associations)"; - } - -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreAssembler.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreAssembler.java b/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreAssembler.java deleted file mode 100644 index 0117834..0000000 --- a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreAssembler.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2008 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.common.Visibility; -import org.qi4j.bootstrap.Assembler; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.entitystore.memory.MemoryEntityStoreService; -import org.qi4j.spi.uuid.UuidIdentityGeneratorService; - -public class JndiEntityStoreAssembler - implements Assembler -{ - private String configurationModuleName; - - public JndiEntityStoreAssembler( String configurationModule ) - { - this.configurationModuleName = configurationModule; - } - - public void assemble( ModuleAssembly module ) throws AssemblyException - { - module.addServices( JndiEntityStoreService.class, UuidIdentityGeneratorService.class ); - ModuleAssembly config = module.layer().module( configurationModuleName ); - config.entities( JndiConfiguration.class ).visibleIn( Visibility.layer ); - config.services( MemoryEntityStoreService.class ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreMixin.java b/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreMixin.java deleted file mode 100644 index c20738a..0000000 --- a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreMixin.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2008 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.configuration.Configuration; -import org.qi4j.api.injection.scope.This; -import org.qi4j.io.Input; -import org.qi4j.io.Output; -import org.qi4j.api.property.Property; -import org.qi4j.api.usecase.Usecase; -import org.qi4j.spi.entity.EntityState; -import org.qi4j.spi.entitystore.EntityStore; -import org.qi4j.spi.entitystore.EntityStoreException; -import org.qi4j.spi.entitystore.EntityStoreUnitOfWork; - -import javax.naming.Context; -import javax.naming.NamingException; -import javax.naming.directory.InitialDirContext; -import java.util.Hashtable; -import org.qi4j.api.service.ServiceActivation; -import org.qi4j.api.structure.Module; - -public class JndiEntityStoreMixin - implements ServiceActivation, EntityStore -{ - @This private Configuration<JndiConfiguration> configuration; - private JndiSetup setup; - - public void activateService() - throws Exception - { - connect(); - } - - private void connect() - throws NamingException - { - JndiConfiguration conf = configuration.get(); - setup = new JndiSetup(); - setup.instanceVersionAttribute = conf.versionAttribute().get(); - if( setup.instanceVersionAttribute == null ) - { - setup.instanceVersionAttribute = "instanceVersion"; - } - setup.lastModifiedDateAttribute = conf.lastModifiedDateAttribute().get(); - if( setup.lastModifiedDateAttribute == null ) - { - setup.lastModifiedDateAttribute = "lastModifiedDate"; - } - setup.identityAttribute = conf.identityAttribute().get(); - if( setup.identityAttribute == null ) - { - setup.identityAttribute = "uid"; - } - setup.qualifiedTypeAttribute = conf.qualifiedTypeAttribute().get(); - setup.baseDn = conf.baseDN().get(); - setup.isReadOnly = conf.readOnly().get(); - - Hashtable<String, String> env = new Hashtable<String, String>(); - addToEnv( env, Context.AUTHORITATIVE, conf.authorative(), null ); - addToEnv( env, Context.BATCHSIZE, conf.batchSize(), null ); - addToEnv( env, Context.DNS_URL, conf.dnsUrl(), null ); - addToEnv( env, Context.INITIAL_CONTEXT_FACTORY, conf.initialContextFactory(), "com.sun.jndi.ldap.LdapCtxFactory" ); - addToEnv( env, Context.LANGUAGE, conf.language(), null ); - addToEnv( env, Context.OBJECT_FACTORIES, conf.objectFactories(), null ); - addToEnv( env, Context.PROVIDER_URL, conf.providerUrl(), null ); - addToEnv( env, Context.REFERRAL, conf.referral(), null ); - addToEnv( env, Context.SECURITY_AUTHENTICATION, conf.securityAuthentication(), null ); - addToEnv( env, Context.SECURITY_CREDENTIALS, conf.securityCredentials(), null ); - addToEnv( env, Context.SECURITY_PRINCIPAL, conf.securityPrincipal(), null ); - addToEnv( env, Context.SECURITY_PROTOCOL, conf.securityProtocol(), null ); - addToEnv( env, Context.STATE_FACTORIES, conf.stateFactories(), null ); - addToEnv( env, Context.URL_PKG_PREFIXES, conf.urlPkgPrefixes(), null ); - setup.context = new InitialDirContext( env ); - } - - private void addToEnv( Hashtable<String, String> env, String key, Property<String> property, String defaultValue ) - { - String value = property.get(); - if( value != null ) - { - env.put( key, value ); - } - else if( defaultValue != null ) - { - env.put( key, defaultValue ); - } - } - - public void passivateService() - throws Exception - { - setup.context.close(); - setup = null; - } - - public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, Module module, long currentTime ) - { - return new JndiUow( setup, usecase, module, currentTime ); - } - - public Input<EntityState, EntityStoreException> entityStates( Module module ) - { - return new Input<EntityState, EntityStoreException>() - { - public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super EntityState, ReceiverThrowableType> output ) - throws EntityStoreException, ReceiverThrowableType - { - // TODO Actual iteration - throw new UnsupportedOperationException( "Not implemented yet!" ); - } - }; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreService.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreService.java b/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreService.java deleted file mode 100644 index f73d5ec..0000000 --- a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiEntityStoreService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2008 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.concern.Concerns; -import org.qi4j.api.configuration.Configuration; -import org.qi4j.api.mixin.Mixins; -import org.qi4j.api.service.ServiceActivation; -import org.qi4j.api.service.ServiceComposite; -import org.qi4j.library.locking.LockingAbstractComposite; -import org.qi4j.spi.entitystore.ConcurrentModificationCheckConcern; -import org.qi4j.spi.entitystore.EntityStore; - -@Concerns( ConcurrentModificationCheckConcern.class ) -@Mixins( JndiEntityStoreMixin.class ) -public interface JndiEntityStoreService extends ServiceActivation, EntityStore, ServiceComposite, LockingAbstractComposite, Configuration -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiSetup.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiSetup.java b/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiSetup.java deleted file mode 100644 index 7b5564e..0000000 --- a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiSetup.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2009 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.entitystore.jndi; - -import javax.naming.directory.InitialDirContext; - -class JndiSetup -{ - InitialDirContext context; - String instanceVersionAttribute; - String lastModifiedDateAttribute; - Boolean isReadOnly; - String identityAttribute; - String baseDn; - String qualifiedTypeAttribute; -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiUow.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiUow.java b/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiUow.java deleted file mode 100644 index 3685f27..0000000 --- a/extensions/entitystore-jndi/src/main/java/org/qi4j/entitystore/jndi/JndiUow.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright 2009 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.entitystore.jndi; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; -import javax.naming.ldap.LdapName; -import org.qi4j.api.association.AssociationDescriptor; -import org.qi4j.api.common.QualifiedName; -import org.qi4j.api.entity.EntityDescriptor; -import org.qi4j.api.entity.EntityReference; -import org.qi4j.api.property.PropertyDescriptor; -import org.qi4j.api.structure.Module; -import org.qi4j.api.usecase.Usecase; -import org.qi4j.spi.entity.EntityState; -import org.qi4j.spi.entity.EntityStatus; -import org.qi4j.spi.entitystore.EntityNotFoundException; -import org.qi4j.spi.entitystore.EntityStoreException; -import org.qi4j.spi.entitystore.EntityStoreUnitOfWork; -import org.qi4j.spi.entitystore.ReadOnlyEntityStoreException; -import org.qi4j.spi.entitystore.StateCommitter; - -public class JndiUow implements EntityStoreUnitOfWork -{ - private static final ArrayList<String> RESTRICTED_PROPERTIES = new ArrayList<String>(); - - static - { - RESTRICTED_PROPERTIES.add( "identity" ); - } - - private long currentTime; - private Usecase usecase; - private Module module; - private String uowIdentity; - private JndiSetup setup; - - public JndiUow( JndiSetup setup, Usecase usecase, Module module, long currentTime ) - { - this.setup = setup; - uowIdentity = UUID.randomUUID().toString(); - this.usecase = usecase; - this.module = module; - this.currentTime = currentTime; - } - - public String identity() - { - return uowIdentity; - } - - public long currentTime() - { - return currentTime; - } - - public EntityState newEntityState( EntityReference anIdentity, EntityDescriptor entityDescriptor ) - throws EntityStoreException - { - throw new ReadOnlyEntityStoreException( "JndiEntityStore is read-only." ); - } - - public EntityState entityStateOf( EntityReference identity ) - throws EntityStoreException, EntityNotFoundException - { - try - { - String id = identity.identity(); - Attributes attrs = lookup( id ); - - String version = Long.toString( getVersion( attrs ) ); - long lastModified = getLastModified( attrs ); - EntityStatus status = EntityStatus.LOADED; - EntityDescriptor descriptor = module.entityDescriptor( getType( attrs ) ); - Map<QualifiedName, Object> properties = getProperties( attrs, descriptor ); - Map<QualifiedName, EntityReference> associations = getAssociations( attrs, descriptor ); - Map<QualifiedName, List<EntityReference>> manyAssocations = getManyAssociations( attrs, descriptor ); - return new JndiEntityState( this, - version, - lastModified, - identity, - status, - descriptor, - properties, - associations, - manyAssocations ); - } - catch( NamingException e ) - { - throw new EntityStoreException( e ); - } - } - - public StateCommitter applyChanges() - throws EntityStoreException - { - return new StateCommitter() - { - public void commit() - { - } - - public void cancel() - { - } - }; - } - - public void discard() - { - } - - private Attributes lookup( String id ) - throws NamingException - { - // TODO: Caching - LdapName dn = new LdapName( setup.identityAttribute + "=" + id + "," + setup.baseDn ); - return setup.context.getAttributes( dn ); - } - - - private String getType( Attributes attrs ) - throws NamingException - { - Attribute typeAttr = attrs.get( setup.qualifiedTypeAttribute ); - if( typeAttr == null ) - { - return null; - } - return (String) typeAttr.get(); - } - - private long getLastModified( Attributes attrs ) - throws NamingException - { - Attribute lastModifiedAttr = attrs.get( setup.lastModifiedDateAttribute ); - if( lastModifiedAttr == null ) - { - return -1; - } - String lastModifiedValue = (String) lastModifiedAttr.get(); - return Long.parseLong( lastModifiedValue ); - } - - private long getVersion( Attributes attrs ) - throws NamingException - { - Attribute versionAttr = attrs.get( setup.instanceVersionAttribute ); - if( versionAttr == null ) - { - return -1; - } - String versionValue = (String) versionAttr.get(); - return Long.parseLong( versionValue ); - } - - - private Map<QualifiedName, Object> getProperties( Attributes attrs, EntityDescriptor entityType ) - throws NamingException - { - Map<QualifiedName, Object> result = new HashMap<QualifiedName, Object>(); - for( PropertyDescriptor property : entityType.state().properties() ) - { - QualifiedName qualifiedName = property.qualifiedName(); - String propertyName = qualifiedName.name(); - if( !RESTRICTED_PROPERTIES.contains( propertyName ) ) - { - Attribute attribute = attrs.get( propertyName ); - if( attribute != null ) - { - result.put( qualifiedName, attribute.get() ); - } - } - } - return result; - } - - private Map<QualifiedName, EntityReference> getAssociations( Attributes attrs, EntityDescriptor entityType ) - throws NamingException - { - Map<QualifiedName, EntityReference> result = new HashMap<QualifiedName, EntityReference>(); - for( AssociationDescriptor associationType : entityType.state().associations() ) - { - QualifiedName qualifiedName = associationType.qualifiedName(); - String associationName = qualifiedName.name(); - Attribute attribute = attrs.get( associationName ); - String identity = (String) attribute.get(); - EntityReference entityReference = EntityReference.parseEntityReference( identity ); - result.put( qualifiedName, entityReference ); - } - return result; - } - - private Map<QualifiedName, List<EntityReference>> getManyAssociations( Attributes attrs, EntityDescriptor entityType ) - throws NamingException - { - Map<QualifiedName, List<EntityReference>> result = new HashMap<QualifiedName, List<EntityReference>>(); - for( AssociationDescriptor associationType : entityType.state().manyAssociations() ) - { - QualifiedName qualifiedName = associationType.qualifiedName(); - String associationName = qualifiedName.name(); - Attribute attribute = attrs.get( associationName ); - String identity = (String) attribute.get(); - EntityReference entityRef = new EntityReference( identity ); - List<EntityReference> entry = result.get( qualifiedName ); - if( entry == null ) - { - entry = new ArrayList<EntityReference>(); - result.put( qualifiedName, entry ); - } - entry.add( entityRef ); - } - return result; - } - - -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/Group.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/Group.java b/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/Group.java deleted file mode 100644 index 39f0977..0000000 --- a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/Group.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2009 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.property.Property; - -public interface Group -{ - Property<String> uid(); - -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/GroupEntity.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/GroupEntity.java b/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/GroupEntity.java deleted file mode 100644 index f000532..0000000 --- a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/GroupEntity.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2009 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.entity.EntityComposite; - -public interface GroupEntity extends Group, EntityComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/JndiReadEntityStoreTest.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/JndiReadEntityStoreTest.java b/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/JndiReadEntityStoreTest.java deleted file mode 100644 index 1e57060..0000000 --- a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/JndiReadEntityStoreTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2009 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.junit.Test; -import org.junit.Assert; -import org.junit.Ignore; -import org.qi4j.api.common.Visibility; -import org.qi4j.api.unitofwork.UnitOfWork; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.spi.uuid.UuidIdentityGeneratorService; -import org.qi4j.test.AbstractQi4jTest; - -import javax.naming.directory.Attributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.InitialDirContext; -import org.qi4j.api.value.ValueSerialization; -import org.qi4j.test.EntityTestAssembler; -import org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService; - -public class JndiReadEntityStoreTest extends AbstractQi4jTest -{ - public void assemble( ModuleAssembly module ) throws AssemblyException - { - module.services( JndiEntityStoreService.class, UuidIdentityGeneratorService.class ); - module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON ); - ModuleAssembly config = module.layer().module( "config" ); - config.entities( JndiConfiguration.class ).visibleIn( Visibility.layer ); - new EntityTestAssembler().assemble( config ); - - module.entities( UserEntity.class, GroupEntity.class ); - } - - @Test - @Ignore( "Requires connection to LDAP server on OPS4J that is now unavailable" ) - public void findSaslSupportTypes() - throws Exception - { - // Create initial context - DirContext ctx = new InitialDirContext(); - - // Read supportedSASLMechanisms from root DSE - Attributes attrs = ctx.getAttributes( - "ldap://srv07.ops4j.org:389", new String[]{ "supportedSASLMechanisms" } ); - - System.out.println( attrs ); - } - - @Test - @Ignore - public void testReadNiclasFromLdap() - throws Exception - { - UnitOfWork uow = module.newUnitOfWork(); - try - { - User user = uow.get( User.class, "niclas.hedhman" ); - System.out.println( user.givenName().get() + " " + user.sn().get() ); - Assert.assertEquals( "Niclas", user.givenName().get() ); - } - finally - { - uow.discard(); - } - } -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/User.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/User.java b/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/User.java deleted file mode 100644 index a656c56..0000000 --- a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/User.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2009 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.property.Property; - -public interface User -{ - Property<String> sn(); - - Property<String> givenName(); -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/UserEntity.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/UserEntity.java b/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/UserEntity.java deleted file mode 100644 index 84ef3e5..0000000 --- a/extensions/entitystore-jndi/src/test/java/org/qi4j/entitystore/jndi/UserEntity.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2009 Niclas Hedhman. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.jndi; - -import org.qi4j.api.entity.EntityComposite; - -public interface UserEntity extends User, EntityComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-jndi/src/test/resources/org/qi4j/entitystore/jndi/JndiEntityStoreService.properties ---------------------------------------------------------------------- diff --git a/extensions/entitystore-jndi/src/test/resources/org/qi4j/entitystore/jndi/JndiEntityStoreService.properties b/extensions/entitystore-jndi/src/test/resources/org/qi4j/entitystore/jndi/JndiEntityStoreService.properties deleted file mode 100644 index 3d41382..0000000 --- a/extensions/entitystore-jndi/src/test/resources/org/qi4j/entitystore/jndi/JndiEntityStoreService.properties +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2008 Niclas Hedhman. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# -# See the License for the specific language governing permissions and -# limitations under the License. - -readOnly=true - -# versionAttribute=instanceVersion - -# qualifiedTypeAttribute - -# turboMode=false - -baseDN=ou=qi4jdev - -# propertyAttribute= - -identityAttribute=cn - -# authorative=false - -# batchSize= - -# controlFactories= - -# dnsUrl= - -# initialContextFactory= - -# language= - -# objectFactories= - -providerUrl=ldap://srv07.ops4j.org:389/dc=codedragons,dc=com - -# referral= - -# securityAuthentication= - -securityCredentials=HappyGoLucky - -securityPrincipal=cn=_tester,ou=qi4jdev,dc=codedragons,dc=com - -# securityProtocol= - -# stateFactories= - -# urlPkgPrefixes= http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/dev-status.xml ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/dev-status.xml b/extensions/entitystore-rmi/dev-status.xml deleted file mode 100644 index 0c93156..0000000 --- a/extensions/entitystore-rmi/dev-status.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<module xmlns="http://www.qi4j.org/schemas/2008/dev-status/1"> - <status> - <codebase>early</codebase> - <!--none,early,beta,stable,mature--> - <documentation>none</documentation> - <!-- none, brief, good, complete --> - <unittests>some</unittests> - <!-- none, some, good, complete --> - </status> - <licenses> - <license>ALv2</license> - </licenses> -</module> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/osgi.bundle ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/osgi.bundle b/extensions/entitystore-rmi/osgi.bundle deleted file mode 100644 index 66452e5..0000000 --- a/extensions/entitystore-rmi/osgi.bundle +++ /dev/null @@ -1,26 +0,0 @@ -Bundle-Activator: - -Private-Package: - -Ignore-Package: com_cenqua_clover - -Import-Package: org.qi4j.api.composite, \ - org.qi4j.api.common, \ - org.qi4j.api.configuration, \ - org.qi4j.api.entity, \ - org.qi4j.api.injection.scope, \ - org.qi4j.api.io, \ - org.qi4j.api.mixin, \ - org.qi4j.api.property, \ - org.qi4j.api.service, \ - org.qi4j.entitystore.map, \ - org.qi4j.library.locking, \ - org.qi4j.spi, \ - org.qi4j.spi.composite, \ - org.qi4j.spi.entity, \ - org.qi4j.spi.entity.helpers, \ - org.qi4j.spi.entitystore, \ - org.qi4j.spi.service, \ - org.qi4j.api.structure - -Export-Package: org.qi4j.entitystore.rmi http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/pom.xml b/extensions/entitystore-rmi/pom.xml deleted file mode 100644 index 1a5640b..0000000 --- a/extensions/entitystore-rmi/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.qi4j.sandbox</groupId> - <artifactId>qi4j-sandbox-extensions</artifactId> - <version>0-SNAPSHOT</version> - </parent> - <groupId>org.qi4j.extension</groupId> - <artifactId>qi4j-entitystore-rmi</artifactId> - <name>Qi4j Extension - EntityStore - RMI</name> - <packaging>jar</packaging> - - <dependencies> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.api</artifactId> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.spi</artifactId> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.bootstrap</artifactId> - </dependency> - <dependency> - <groupId>org.qi4j.library</groupId> - <artifactId>org.qi4j.library.locking</artifactId> - </dependency> - - <!-- For tests --> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.testsupport</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.runtime</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/ClientRmiEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/ClientRmiEntityStoreMixin.java b/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/ClientRmiEntityStoreMixin.java deleted file mode 100644 index a44105b..0000000 --- a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/ClientRmiEntityStoreMixin.java +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2008 Rickard Ãberg. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.rmi; - -import org.qi4j.api.entity.EntityReference; -import org.qi4j.io.Input; -import org.qi4j.io.Output; -import org.qi4j.spi.entitystore.EntityStoreException; - -import java.io.IOException; -import java.io.Reader; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import org.qi4j.api.service.ServiceActivation; -import org.qi4j.spi.entitystore.helpers.MapEntityStore; - -/** - * RMI client implementation of Entity - */ -public class ClientRmiEntityStoreMixin - implements ServiceActivation, MapEntityStore -{ - private RemoteEntityStore remote; - - // Activatable implementation - public void activateService() - throws Exception - { - Registry registry = LocateRegistry.getRegistry( "localhost" ); - remote = (RemoteEntityStore) registry.lookup( ServerRmiEntityStoreService.class.getSimpleName() ); - } - - public void passivateService() - throws Exception - { - remote = null; - } - - public Reader get( EntityReference entityReference ) - throws EntityStoreException - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public Input<Reader, IOException> entityStates() - { - return new Input<Reader, IOException>() - { - public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output ) - throws IOException, ReceiverThrowableType - { - // TODO Implement this - throw new UnsupportedOperationException( "Not supported yet." ); - } - }; - } - - public void applyChanges( MapChanges changes ) - throws IOException - { - //To change body of implemented methods use File | Settings | File Templates. - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/ClientRmiEntityStoreService.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/ClientRmiEntityStoreService.java b/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/ClientRmiEntityStoreService.java deleted file mode 100644 index f46424c..0000000 --- a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/ClientRmiEntityStoreService.java +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2008 Rickard Ãberg. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.qi4j.entitystore.rmi; - -import org.qi4j.api.mixin.Mixins; -import org.qi4j.api.service.ServiceActivation; -import org.qi4j.library.locking.LockingAbstractComposite; -import org.qi4j.spi.entitystore.EntityStore; - -/** - * EntityStore service for remote access of another EntityStore. - */ - -@Mixins( { ClientRmiEntityStoreMixin.class } ) -public interface ClientRmiEntityStoreService - extends EntityStore, ServiceActivation, LockingAbstractComposite -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryConfiguration.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryConfiguration.java b/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryConfiguration.java deleted file mode 100644 index a2eaa8b..0000000 --- a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryConfiguration.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.qi4j.entitystore.rmi; - -import org.qi4j.api.configuration.ConfigurationComposite; -import org.qi4j.api.property.Property; - -/** - * JAVADOC - */ -public interface RegistryConfiguration - extends ConfigurationComposite -{ - Property<Integer> port(); -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryMixin.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryMixin.java b/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryMixin.java deleted file mode 100644 index 198e11f..0000000 --- a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryMixin.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.qi4j.entitystore.rmi; - -import org.qi4j.api.common.AppliesTo; -import org.qi4j.api.configuration.Configuration; -import org.qi4j.api.injection.scope.This; -import org.qi4j.api.service.ServiceActivation; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import java.rmi.server.UnicastRemoteObject; - -/** - * Create and delegate to a RMI registry. - */ -@AppliesTo( { Registry.class, ServiceActivation.class } ) -public class RegistryMixin - implements InvocationHandler, ServiceActivation -{ - Registry registry; - - @This Configuration<RegistryConfiguration> config; - - public void activateService() throws Exception - { - try - { - Integer port = config.get().port().get(); - registry = LocateRegistry.createRegistry( port ); - } - catch( RemoteException e ) - { - registry = LocateRegistry.getRegistry(); - } - } - - public void passivateService() throws Exception - { - for( String boundService : registry.list() ) - { - registry.unbind( boundService ); - } - UnicastRemoteObject.unexportObject( registry, true ); - } - - public Object invoke( Object o, Method method, Object[] objects ) throws Throwable - { - return method.invoke( registry, objects ); - } - -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryService.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryService.java b/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryService.java deleted file mode 100644 index 7adbc7d..0000000 --- a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RegistryService.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.qi4j.entitystore.rmi; - -import org.qi4j.api.mixin.Mixins; -import org.qi4j.api.service.ServiceActivation; - -import java.rmi.registry.Registry; - -/** - * RMI Registry service - */ -@Mixins( RegistryMixin.class ) -public interface RegistryService - extends ServiceActivation, Registry -{ -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/d4dd9c17/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RemoteEntityStore.java ---------------------------------------------------------------------- diff --git a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RemoteEntityStore.java b/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RemoteEntityStore.java deleted file mode 100644 index 0e91190..0000000 --- a/extensions/entitystore-rmi/src/main/java/org/qi4j/entitystore/rmi/RemoteEntityStore.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.qi4j.entitystore.rmi; - -import java.io.IOException; -import java.rmi.Remote; -import org.qi4j.spi.entity.EntityState; -import org.qi4j.spi.entity.QualifiedIdentity; -import org.qi4j.spi.entitystore.ConcurrentEntityStateModificationException; - -/** - * Interface for remote EntityStore - */ -public interface RemoteEntityStore - extends Remote -{ - EntityState getEntityState( QualifiedIdentity identity ) - throws IOException; - - void prepare( Iterable<EntityState> newStates, Iterable<EntityState> loadedStates, Iterable<QualifiedIdentity> removedStates ) - throws IOException, ConcurrentEntityStateModificationException; -}
