http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/lookup/src/main/java/org/qi4j/library/jini/lookup/Streams.java ---------------------------------------------------------------------- diff --git a/libraries/jini/lookup/src/main/java/org/qi4j/library/jini/lookup/Streams.java b/libraries/jini/lookup/src/main/java/org/qi4j/library/jini/lookup/Streams.java deleted file mode 100644 index cf6f42a..0000000 --- a/libraries/jini/lookup/src/main/java/org/qi4j/library/jini/lookup/Streams.java +++ /dev/null @@ -1,81 +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.library.jini.lookup; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -public class Streams -{ - public static void copyStream( InputStream src, OutputStream dest, boolean closeAfterCopy ) - throws IOException - { - BufferedInputStream in = null; - BufferedOutputStream out = null; - try - { - if( src instanceof BufferedInputStream ) - { - in = (BufferedInputStream) src; - } - else - { - in = new BufferedInputStream( src ); - } - if( dest instanceof BufferedOutputStream ) - { - out = (BufferedOutputStream) dest; - } - else - { - out = new BufferedOutputStream( dest ); - } - - byte[] buffer = new byte[1024]; - int count = 0; - do - { - count = in.read( buffer ); - if( count > 0 ) - { - out.write( buffer, 0, count ); - } - } - while( count != -1 ); - out.flush(); - } - finally - { - if( closeAfterCopy ) - { - if( in != null ) - { - in.close(); - } - if( out != null ) - { - out.close(); - } - } - } - } -}
http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/jini.config ---------------------------------------------------------------------- diff --git a/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/jini.config b/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/jini.config deleted file mode 100644 index 0a963e3..0000000 --- a/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/jini.config +++ /dev/null @@ -1,9 +0,0 @@ - -import java.net.InetAddress; -import java.net.NetworkInterface; - -net.jini.discovery.LookupDiscovery -{ - multicastInterfaces = new NetworkInterface[] { NetworkInterface.getByInetAddress( InetAddress.getByName( "127.0.0.1" ) ) }; - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/reggie-2.1.1.jar ---------------------------------------------------------------------- diff --git a/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/reggie-2.1.1.jar b/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/reggie-2.1.1.jar deleted file mode 100644 index a85c3be..0000000 Binary files a/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/reggie-2.1.1.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/reggie-dl-2.1.1.jar ---------------------------------------------------------------------- diff --git a/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/reggie-dl-2.1.1.jar b/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/reggie-dl-2.1.1.jar deleted file mode 100644 index d8bda88..0000000 Binary files a/libraries/jini/lookup/src/main/resources/org/qi4j/library/jini/lookup/reggie-dl-2.1.1.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/lookup/src/test/java/org/qi4j/library/jini/lookup/ReggieStartTest.java ---------------------------------------------------------------------- diff --git a/libraries/jini/lookup/src/test/java/org/qi4j/library/jini/lookup/ReggieStartTest.java b/libraries/jini/lookup/src/test/java/org/qi4j/library/jini/lookup/ReggieStartTest.java deleted file mode 100644 index 5444ead..0000000 --- a/libraries/jini/lookup/src/test/java/org/qi4j/library/jini/lookup/ReggieStartTest.java +++ /dev/null @@ -1,204 +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.library.jini.lookup; - -import net.jini.core.lookup.ServiceRegistrar; -import net.jini.core.lookup.ServiceTemplate; -import net.jini.discovery.DiscoveryEvent; -import net.jini.discovery.DiscoveryListener; -import net.jini.discovery.DiscoveryManagement; -import net.jini.discovery.LookupDiscoveryManager; -import net.jini.lookup.LookupCache; -import net.jini.lookup.ServiceDiscoveryEvent; -import net.jini.lookup.ServiceDiscoveryListener; -import net.jini.lookup.ServiceDiscoveryManager; -import net.jini.security.policy.DynamicPolicyProvider; -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.qi4j.api.injection.scope.Service; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.entitystore.memory.MemoryEntityStoreService; -import org.qi4j.library.http.JettyServiceAssembler; -import org.qi4j.test.AbstractQi4jTest; - -import java.io.IOException; -import java.security.*; -import java.util.Collection; -import java.util.logging.*; - -public class ReggieStartTest extends AbstractQi4jTest -{ - private static Logger logger = Logger.getLogger( "" ); - - static - { - Handler[] handlers = logger.getHandlers(); - for( Handler handler : handlers ) - { - Formatter formatter = new SimpleFormatter(); - handler.setFormatter( formatter ); - } - logger.setLevel( Level.FINEST ); - if( System.getSecurityManager() == null ) - { - Policy basePolicy = new AllPolicy(); - DynamicPolicyProvider policyProvider = new DynamicPolicyProvider( basePolicy ); - Policy.setPolicy( policyProvider ); - System.setSecurityManager( new SecurityManager() ); - } - } - - - public void assemble( ModuleAssembly module ) throws AssemblyException - { - new JettyServiceAssembler().assemble( module ); - module.addObjects( Holder.class ); - module.addServices( MemoryEntityStoreService.class ); - new JiniLookupServiceAssembler().assemble( module ); - } - - @Test - public void whenStartingReggieExpectFoundServiceRegistrar() - throws Exception - { - LookupCache cache = initialize(); - MyServiceDiscoveryListener listener = new MyServiceDiscoveryListener(); - cache.addListener( listener ); - Holder object = objectBuilderFactory.newObject( Holder.class ); - synchronized( this ) - { - if( !listener.added ) - { - wait( 25000 ); - } - } - synchronized( listener ) - { - assertTrue( listener.added ); - } - } - - - private LookupCache initialize() - throws IOException - { - DiscoveryManagement discoveryManager = new LookupDiscoveryManager( null, null, new MyDiscoveryListener() ); - ServiceDiscoveryManager sdm = new ServiceDiscoveryManager( discoveryManager, null ); - Class[] types = new Class[]{ ServiceRegistrar.class }; - ServiceTemplate template = new ServiceTemplate( null, types, null ); - LookupCache lookupCache = sdm.createLookupCache( template, null, null ); - return lookupCache; - - } - - public static class Holder - { - @Service ServiceRegistryService service; - } - - private static class MyDiscoveryListener - implements DiscoveryListener - { - - public void discovered( DiscoveryEvent e ) - { - printEvent( e, "Discovered: " ); - } - - public void discarded( DiscoveryEvent e ) - { - printEvent( e, "Discarded: " ); - } - - private void printEvent( DiscoveryEvent e, String message ) - { - Collection<String[]> collection = e.getGroups().values(); - for( String[] array : collection ) - { - StringBuffer groups = new StringBuffer(); - boolean first = true; - for( String group : array ) - { - if( !first ) - { - groups.append( "," ); - } - first = false; - groups.append( group ); - System.out.println( message + groups ); - } - } - } - } - - private class MyServiceDiscoveryListener - implements ServiceDiscoveryListener - { - boolean added = false; - boolean removed = false; - - public MyServiceDiscoveryListener() - { - } - - public void serviceAdded( ServiceDiscoveryEvent event ) - { - synchronized( ReggieStartTest.this ) - { - logger.info( "Added: " + event.getPostEventServiceItem() ); - added = true; - ReggieStartTest.this.notifyAll(); - } - } - - public void serviceRemoved( ServiceDiscoveryEvent event ) - { - synchronized( ReggieStartTest.this ) - { - logger.info( "Removed: " + event.getPostEventServiceItem() ); - removed = true; - ReggieStartTest.this.notifyAll(); - } - } - - public void serviceChanged( ServiceDiscoveryEvent event ) - { - } - } - - public static class AllPolicy extends Policy - { - - public AllPolicy() - { - } - - public PermissionCollection getPermissions( CodeSource codeSource ) - { - Permissions allPermission; - allPermission = new Permissions(); - allPermission.add( new AllPermission() ); - return allPermission; - } - - public void refresh() - { - } - } -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/lookup/src/test/resources/org/qi4j/library/http/JettyService.properties ---------------------------------------------------------------------- diff --git a/libraries/jini/lookup/src/test/resources/org/qi4j/library/http/JettyService.properties b/libraries/jini/lookup/src/test/resources/org/qi4j/library/http/JettyService.properties deleted file mode 100644 index 7a1adb8..0000000 --- a/libraries/jini/lookup/src/test/resources/org/qi4j/library/http/JettyService.properties +++ /dev/null @@ -1,3 +0,0 @@ -port=8040 -hostName=127.0.0.1 -resourcePath=/ http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/pom.xml ---------------------------------------------------------------------- diff --git a/libraries/jini/pom.xml b/libraries/jini/pom.xml deleted file mode 100644 index b7a59ff..0000000 --- a/libraries/jini/pom.xml +++ /dev/null @@ -1,21 +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/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.qi4j.sandbox</groupId> - <artifactId>qi4j-sandbox-libraries</artifactId> - <version>0-SNAPSHOT</version> - </parent> - <groupId>org.qi4j.library.jini</groupId> - <artifactId>org.qi4j.library.jini</artifactId> - <name>Qi4j Library - Jini</name> - <packaging>pom</packaging> - - <modules> - <!--<module>common</module>--> - <module>importer</module> - <module>lookup</module> - <module>transaction</module> - <module>javaspaces</module> - </modules> -</project> http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/dev-status.xml ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/dev-status.xml b/libraries/jini/transaction/dev-status.xml deleted file mode 100644 index dc92d29..0000000 --- a/libraries/jini/transaction/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>brief</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/25dbfc23/libraries/jini/transaction/pom.xml ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/pom.xml b/libraries/jini/transaction/pom.xml deleted file mode 100644 index 1c8d0eb..0000000 --- a/libraries/jini/transaction/pom.xml +++ /dev/null @@ -1,77 +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/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.qi4j.library.jini</groupId> - <artifactId>org.qi4j.library.jini</artifactId> - <version>0-SNAPSHOT</version> - </parent> - <groupId>org.qi4j.library.jini</groupId> - <artifactId>org.qi4j.library.jini-transaction</artifactId> - <name>Qi4j Library - Jini Transaction Service</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.runtime</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.bootstrap</artifactId> - </dependency> - <dependency> - <groupId>org.qi4j.library</groupId> - <artifactId>org.qi4j.library.http</artifactId> - <version>${version.qi4j}</version> - </dependency> - <dependency> - <groupId>org.qi4j.library</groupId> - <artifactId>org.qi4j.library.logging</artifactId> - <version>${version.qi4j}</version> - </dependency> - <dependency> - <groupId>org.qi4j.library.jini</groupId> - <artifactId>org.qi4j.library.jini-lookup</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.river</groupId> - <artifactId>jini-core</artifactId> - <version>2.1.1</version> - </dependency> - <dependency> - <groupId>org.apache.river</groupId> - <artifactId>jini-ext</artifactId> - <version>2.1.1</version> - </dependency> - <dependency> - <groupId>org.apache.river</groupId> - <artifactId>mahalo</artifactId> - <version>2.1.1</version> - </dependency> - <dependency> - <groupId>org.apache.river</groupId> - <artifactId>start</artifactId> - <version>2.1.1</version> - </dependency> - <dependency> - <groupId>org.apache.river</groupId> - <artifactId>jsk-lib</artifactId> - <version>2.1.1</version> - </dependency> - <dependency> - <groupId>org.qi4j.core</groupId> - <artifactId>org.qi4j.core.testsupport</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/JiniTransactionServiceAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/JiniTransactionServiceAssembler.java b/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/JiniTransactionServiceAssembler.java deleted file mode 100644 index a1bd518..0000000 --- a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/JiniTransactionServiceAssembler.java +++ /dev/null @@ -1,36 +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.library.jini.transaction; - -import org.qi4j.bootstrap.Assembler; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.library.http.ServletInfo; - -public class JiniTransactionServiceAssembler - implements Assembler -{ - public void assemble( ModuleAssembly module ) - throws AssemblyException - { - module.addEntities( MahaloConfiguration.class ); - ServletInfo servletInfo = new ServletInfo( "/jini/mahalo-dl.jar" ); - module.addServices( MahaloDownloadServletService.class ).instantiateOnStartup().setMetaInfo( servletInfo ); - module.addServices( TransactionManagerService.class ).instantiateOnStartup(); - } -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloConfiguration.java ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloConfiguration.java b/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloConfiguration.java deleted file mode 100644 index 24816d6..0000000 --- a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloConfiguration.java +++ /dev/null @@ -1,36 +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.library.jini.transaction; - -import org.qi4j.api.common.Optional; -import org.qi4j.api.common.UseDefaults; -import org.qi4j.api.configuration.ConfigurationComposite; -import org.qi4j.api.property.Property; - -public interface MahaloConfiguration extends ConfigurationComposite -{ - @Optional @UseDefaults Property<Boolean> useJrmp(); - - @Optional Property<String> hostInterface(); - - @Optional Property<String> securityPolicy(); - - @Optional Property<String> mahaloDlJarLocation(); - - @Optional Property<String> groups(); -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloDownloadServletService.java ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloDownloadServletService.java b/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloDownloadServletService.java deleted file mode 100644 index 78daaf9..0000000 --- a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloDownloadServletService.java +++ /dev/null @@ -1,28 +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.library.jini.transaction; - -import org.qi4j.api.mixin.Mixins; -import org.qi4j.api.service.ServiceComposite; - -import javax.servlet.Servlet; - -@Mixins( ResourceServletMixin.class ) -public interface MahaloDownloadServletService extends Servlet, ServiceComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloMixin.java ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloMixin.java b/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloMixin.java deleted file mode 100644 index e155b9e..0000000 --- a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/MahaloMixin.java +++ /dev/null @@ -1,247 +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.library.jini.transaction; - -import com.sun.jini.admin.DestroyAdmin; -import com.sun.jini.start.NonActivatableServiceDescriptor; -import net.jini.admin.Administrable; -import net.jini.config.Configuration; -import net.jini.config.EmptyConfiguration; -import org.qi4j.api.common.Optional; -import org.qi4j.api.injection.scope.Service; -import org.qi4j.api.injection.scope.This; -import org.qi4j.api.service.Activatable; -import org.qi4j.library.http.HttpService; -import org.qi4j.library.http.Interface; -import org.qi4j.library.jini.lookup.Streams; - -import java.io.*; -import java.net.UnknownHostException; -import java.security.Policy; -import java.util.ArrayList; -import java.util.StringTokenizer; - -public class MahaloMixin - implements Activatable -{ - @Optional @Service HttpService httpService; - @This org.qi4j.api.configuration.Configuration<MahaloConfiguration> my; - - private NonActivatableServiceDescriptor.Created lookupCreated; - private File fileToCleanup; - - public void activate() - throws Exception - { - // Prepare a temporary directory. - File qi4j = new File( "qi4jtemp" ); - qi4j.mkdir(); - fileToCleanup = qi4j.getAbsoluteFile(); - File jini = new File( qi4j, "jini" ); - jini.mkdirs(); - File temp = File.createTempFile( "mahalo", "", jini ); - temp.delete(); - temp.mkdirs(); - Configuration serviceDescConfig = EmptyConfiguration.INSTANCE; - String httpURLtext = my.configuration().mahaloDlJarLocation().get(); - if( httpURLtext == null ) - { - // If Http Service not running in this JVM, we need the Download URL from configuration. - if( httpService != null ) - { - httpURLtext = constructDownloadURL(); - } - } - String mahaloJarLocation = createMahaloJars( temp ); - File mahaloJarFile = new File( mahaloJarLocation ); - String securityPolicyLocation = createSecurityPolicy( temp, mahaloJarFile ); - String mahaloConfig = createMahaloConfig( temp ); - System.out.println( "Policy: " + Policy.getPolicy() ); - NonActivatableServiceDescriptor serviceDescriptor = new NonActivatableServiceDescriptor( - httpURLtext, - securityPolicyLocation, - mahaloJarLocation, - "com.sun.jini.mahalo.TransientMahaloImpl", - new String[]{ mahaloConfig } ); - lookupCreated = (NonActivatableServiceDescriptor.Created) serviceDescriptor.create( serviceDescConfig ); - - } - - public void passivate() - throws Exception - { - System.out.println( "Destroying Mahalo." ); - Object admin = ( (Administrable) lookupCreated.proxy ).getAdmin(); - ( (DestroyAdmin) admin ).destroy(); - removeFile( fileToCleanup ); - } - - private String createMahaloConfig( File dir ) - throws IOException - { - StringBuffer configuration = new StringBuffer(); - if( my.configuration().useJrmp().get() ) - { - System.out.println( "Using JRMP..." ); - configuration.append( "import net.jini.jrmp.JrmpExporter;\n" + - "\n" + - "com.sun.jini.mahalo\n" + - "{\n" + - " serverExporter = new JrmpExporter();\n" ); - } - else - { - System.out.println( "Using JERI..." ); - configuration.append( "import net.jini.jeri.BasicILFactory;\n" + - "import net.jini.jeri.BasicJeriExporter;\n" + - "import net.jini.jeri.tcp.TcpServerEndpoint;\n" + - "\n" + - "com.sun.jini.mahalo\n" + - "{\n" + - " private invocationLayerFactory = new BasicILFactory();\n" + - " serverExporter = new BasicJeriExporter(TcpServerEndpoint.getInstance(0),\n" + - " invocationLayerFactory,\n" + - " false,\n" + - " true);\n" ); - } - configuration.append( " initialLookupGroups = new String[] {" ); - String groupData = my.configuration().groups().get(); - String[] groups; - if( groupData != null ) - { - groups = convert( groupData ); - } - else - { - groups = new String[]{ "qi4j" }; - } - boolean first = true; - for( String group : groups ) - { - if( !first ) - { - configuration.append( ", " ); - } - first = false; - configuration.append( "\"" ); - configuration.append( group ); - configuration.append( "\"" ); - } - - configuration.append( "};\n}" ); - File configFile = new File( dir, "mahalo.conf" ); - if( !configFile.exists() ) - { - InputStream config = new ByteArrayInputStream( configuration.toString().getBytes() ); - copyStreamToFile( config, configFile ); - } - return configFile.getAbsolutePath(); - } - - private String[] convert( String data ) - { - if( data == null ) - { - return new String[0]; - } - ArrayList<String> result = new ArrayList<String>(); - StringTokenizer st = new StringTokenizer( data, ",", false ); - while( st.hasMoreTokens() ) - { - String token = st.nextToken(); - result.add( token ); - } - String[] retVal = new String[result.size()]; - return result.toArray( retVal ); - } - - - private String createMahaloJars( File temp ) - throws IOException - { - File mahaloJar = new File( temp, "mahalo-2.1.1.jar" ); - if( !mahaloJar.exists() ) - { - InputStream mahalo = getClass().getResourceAsStream( "mahalo-2.1.1.jar" ); - copyStreamToFile( mahalo, mahaloJar ); - } - return mahaloJar.getAbsolutePath(); - } - - private void removeFile( File fileToCleanup ) - { - if( fileToCleanup == null ) - { - return; - } - - File[] files = fileToCleanup.listFiles(); - if( files == null ) - { - return; - } - for( File file : files ) - { - removeFile( file ); - } - fileToCleanup.delete(); - } - - private String constructDownloadURL() - throws UnknownHostException - { - Interface[] interfaces = httpService.interfacesServed(); - String host = interfaces[ 0 ].hostName(); - int port = interfaces[ 0 ].port(); - String protocol = interfaces[ 0 ].protocol().toString(); - return protocol + "://" + host + ":" + port + "/jini/mahalo-dl.jar"; - } - - private String createSecurityPolicy( File tempDir, File mahaloJarFile ) - throws IOException - { - String securityPolicy = my.configuration().securityPolicy().get(); - if( securityPolicy == null || "".equals( securityPolicy ) ) - { - securityPolicy = "grant { permission java.security.AllPermission; };"; - } - File securityPolicyFile = new File( tempDir, "mahalo-security.policy" ); - copyStringToFile( securityPolicy, securityPolicyFile ); - return securityPolicyFile.getAbsolutePath(); - } - - private void copyStringToFile( String securityPolicy, File securityPolicyFile ) - throws IOException - { - ByteArrayInputStream bais = new ByteArrayInputStream( securityPolicy.getBytes() ); - copyStreamToFile( bais, securityPolicyFile ); - } - - private void copyStreamToFile( InputStream inputStream, File destinationFile ) - throws IOException - { - destinationFile = destinationFile.getAbsoluteFile(); - File parentFile = destinationFile.getParentFile(); - if( !parentFile.exists() ) - { - parentFile.mkdirs(); - } - FileOutputStream fos = new FileOutputStream( destinationFile ); - Streams.copyStream( inputStream, fos, true ); - } -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/ResourceServletMixin.java ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/ResourceServletMixin.java b/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/ResourceServletMixin.java deleted file mode 100644 index cd80c20..0000000 --- a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/ResourceServletMixin.java +++ /dev/null @@ -1,39 +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.library.jini.transaction; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import org.qi4j.library.jini.lookup.Streams; - -public class ResourceServletMixin extends HttpServlet -{ - protected void doGet( HttpServletRequest request, HttpServletResponse response ) - throws ServletException, IOException - { - InputStream in = getClass().getResourceAsStream( "mahalo-dl-2.1.1.jar" ); - response.setContentType( "application/java" ); - OutputStream out = response.getOutputStream(); - Streams.copyStream( in, out, true ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/TransactionManagerService.java ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/TransactionManagerService.java b/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/TransactionManagerService.java deleted file mode 100644 index 5e03792..0000000 --- a/libraries/jini/transaction/src/main/java/org/qi4j/library/jini/transaction/TransactionManagerService.java +++ /dev/null @@ -1,27 +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.library.jini.transaction; - -import org.qi4j.api.mixin.Mixins; -import org.qi4j.api.service.Activatable; -import org.qi4j.api.service.ServiceComposite; - -@Mixins( MahaloMixin.class ) -public interface TransactionManagerService extends Activatable, ServiceComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/main/resources/org/qi4j/library/jini/transaction/mahalo-2.1.1.jar ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/main/resources/org/qi4j/library/jini/transaction/mahalo-2.1.1.jar b/libraries/jini/transaction/src/main/resources/org/qi4j/library/jini/transaction/mahalo-2.1.1.jar deleted file mode 100644 index 878729f..0000000 Binary files a/libraries/jini/transaction/src/main/resources/org/qi4j/library/jini/transaction/mahalo-2.1.1.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/main/resources/org/qi4j/library/jini/transaction/mahalo-dl-2.1.1.jar ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/main/resources/org/qi4j/library/jini/transaction/mahalo-dl-2.1.1.jar b/libraries/jini/transaction/src/main/resources/org/qi4j/library/jini/transaction/mahalo-dl-2.1.1.jar deleted file mode 100644 index dbe4ff8..0000000 Binary files a/libraries/jini/transaction/src/main/resources/org/qi4j/library/jini/transaction/mahalo-dl-2.1.1.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/test/java/org/qi4j/library/jini/transaction/MahaloStartTest.java ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/test/java/org/qi4j/library/jini/transaction/MahaloStartTest.java b/libraries/jini/transaction/src/test/java/org/qi4j/library/jini/transaction/MahaloStartTest.java deleted file mode 100644 index 6420385..0000000 --- a/libraries/jini/transaction/src/test/java/org/qi4j/library/jini/transaction/MahaloStartTest.java +++ /dev/null @@ -1,207 +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.library.jini.transaction; - -import net.jini.core.lookup.ServiceTemplate; -import net.jini.core.transaction.server.TransactionManager; -import net.jini.discovery.DiscoveryEvent; -import net.jini.discovery.DiscoveryListener; -import net.jini.discovery.DiscoveryManagement; -import net.jini.discovery.LookupDiscoveryManager; -import net.jini.lookup.LookupCache; -import net.jini.lookup.ServiceDiscoveryEvent; -import net.jini.lookup.ServiceDiscoveryListener; -import net.jini.lookup.ServiceDiscoveryManager; -import net.jini.security.policy.DynamicPolicyProvider; -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.qi4j.api.injection.scope.Service; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.entitystore.memory.MemoryEntityStoreService; -import org.qi4j.library.http.JettyServiceAssembler; -import org.qi4j.library.jini.lookup.JiniLookupServiceAssembler; -import org.qi4j.test.AbstractQi4jTest; - -import java.io.IOException; -import java.security.*; -import java.util.Collection; -import java.util.logging.*; - -public class MahaloStartTest extends AbstractQi4jTest -{ - private static Logger logger = Logger.getLogger( "" ); - - static - { - Handler[] handlers = logger.getHandlers(); - for( Handler handler : handlers ) - { - Formatter formatter = new SimpleFormatter(); - handler.setFormatter( formatter ); - } - logger.setLevel( Level.FINEST ); - - if( System.getSecurityManager() == null ) - { - Policy basePolicy = new AllPolicy(); - DynamicPolicyProvider policyProvider = new DynamicPolicyProvider( basePolicy ); - Policy.setPolicy( policyProvider ); - System.setSecurityManager( new SecurityManager() ); - } - } - - - public void assemble( ModuleAssembly module ) throws AssemblyException - { - new JettyServiceAssembler().assemble( module ); - new JiniLookupServiceAssembler().assemble( module ); - module.addObjects( Holder.class ); - module.addServices( MemoryEntityStoreService.class ); - new JiniTransactionServiceAssembler().assemble( module ); - } - - @Test - public void whenStartingMahaloExpectFoundTransactionManager() - throws Exception - { - LookupCache cache = initialize(); - MyServiceDiscoveryListener listener = new MyServiceDiscoveryListener(); - cache.addListener( listener ); - Holder object = objectBuilderFactory.newObject( Holder.class ); - synchronized( this ) - { - if( !listener.added ) - { - wait( 25000 ); - } - } - synchronized( listener ) - { - assertTrue( listener.added ); - } - } - - - private LookupCache initialize() - throws IOException - { - DiscoveryManagement discoveryManager = new LookupDiscoveryManager( null, null, new MyDiscoveryListener() ); - ServiceDiscoveryManager sdm = new ServiceDiscoveryManager( discoveryManager, null ); - Class[] types = new Class[]{ TransactionManager.class }; - ServiceTemplate template = new ServiceTemplate( null, types, null ); - LookupCache lookupCache = sdm.createLookupCache( template, null, null ); - return lookupCache; - } - - public static class Holder - { - @Service TransactionManagerService service; - } - - private static class MyDiscoveryListener - implements DiscoveryListener - { - - public void discovered( DiscoveryEvent e ) - { - printEvent( e, "Discovered: " ); - } - - public void discarded( DiscoveryEvent e ) - { - printEvent( e, "Discarded: " ); - } - - private void printEvent( DiscoveryEvent e, String message ) - { - System.out.println( e ); - Collection<String[]> collection = e.getGroups().values(); - for( String[] array : collection ) - { - StringBuffer groups = new StringBuffer(); - boolean first = true; - for( String group : array ) - { - if( !first ) - { - groups.append( "," ); - } - first = false; - groups.append( group ); - } - System.out.println( message + groups ); - } - } - } - - private class MyServiceDiscoveryListener - implements ServiceDiscoveryListener - { - boolean added = false; - boolean removed = false; - - public MyServiceDiscoveryListener() - { - } - - public void serviceAdded( ServiceDiscoveryEvent event ) - { - synchronized( MahaloStartTest.this ) - { - logger.info( "Added: " + event.getPostEventServiceItem() ); - added = true; - MahaloStartTest.this.notifyAll(); - } - } - - public void serviceRemoved( ServiceDiscoveryEvent event ) - { - synchronized( MahaloStartTest.this ) - { - logger.info( "Removed: " + event.getPostEventServiceItem() ); - removed = true; - MahaloStartTest.this.notifyAll(); - } - } - - public void serviceChanged( ServiceDiscoveryEvent event ) - { - } - } - - public static class AllPolicy extends Policy - { - - public AllPolicy() - { - } - - public PermissionCollection getPermissions( CodeSource codeSource ) - { - Permissions allPermission; - allPermission = new Permissions(); - allPermission.add( new AllPermission() ); - return allPermission; - } - - public void refresh() - { - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/jini/transaction/src/test/resources/org/qi4j/library/http/JettyService.properties ---------------------------------------------------------------------- diff --git a/libraries/jini/transaction/src/test/resources/org/qi4j/library/http/JettyService.properties b/libraries/jini/transaction/src/test/resources/org/qi4j/library/http/JettyService.properties deleted file mode 100644 index 7a1adb8..0000000 --- a/libraries/jini/transaction/src/test/resources/org/qi4j/library/http/JettyService.properties +++ /dev/null @@ -1,3 +0,0 @@ -port=8040 -hostName=127.0.0.1 -resourcePath=/ http://git-wip-us.apache.org/repos/asf/zest-sandbox/blob/25dbfc23/libraries/pom.xml ---------------------------------------------------------------------- diff --git a/libraries/pom.xml b/libraries/pom.xml index 9aeae7d..e7297e7 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -22,11 +22,5 @@ <module>thread</module> <module>unitofwork</module> <module>validation</module> - - <!-- Depends on incubator release of Apache River. - Could not find a repository with the correct JARs. - Unable to make it compile against Apache River TLP artifacts. - <module>jini</module> --> - </modules> </project>
