You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by io...@apache.org on 2011/08/27 16:09:55 UTC
svn commit: r1162357 - in /karaf/cellar/trunk/samples: ./ hazelcast-app/
hazelcast-app/src/ hazelcast-app/src/main/ hazelcast-app/src/main/java/
hazelcast-app/src/main/java/org/ hazelcast-app/src/main/java/org/apache/
hazelcast-app/src/main/java/org/ap...
Author: iocanel
Date: Sat Aug 27 14:09:54 2011
New Revision: 1162357
URL: http://svn.apache.org/viewvc?rev=1162357&view=rev
Log:
[KARAF-837] Added missing files.
Added:
karaf/cellar/trunk/samples/hazelcast-app/
karaf/cellar/trunk/samples/hazelcast-app/NOTICE
karaf/cellar/trunk/samples/hazelcast-app/README
karaf/cellar/trunk/samples/hazelcast-app/pom.xml
karaf/cellar/trunk/samples/hazelcast-app/src/
karaf/cellar/trunk/samples/hazelcast-app/src/main/
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Activator.java
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Message.java
karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/MessageListener.java
karaf/cellar/trunk/samples/pom.xml
Added: karaf/cellar/trunk/samples/hazelcast-app/NOTICE
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/samples/hazelcast-app/NOTICE?rev=1162357&view=auto
==============================================================================
--- karaf/cellar/trunk/samples/hazelcast-app/NOTICE (added)
+++ karaf/cellar/trunk/samples/hazelcast-app/NOTICE Sat Aug 27 14:09:54 2011
@@ -0,0 +1,44 @@
+Apache Karaf Cellar
+Copyright 2011 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software written by
+Antony Lesuisse.
+Licensed under Public Domain.
+
+
+II. Used Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2010).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+JLine (http://jline.sourceforge.net).
+Licensed under the BSD License.
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+This product includes software from http://www.json.org.
+Copyright (c) 2002 JSON.org
+
+
+III. License Summary
+- Apache License 2.0
Added: karaf/cellar/trunk/samples/hazelcast-app/README
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/samples/hazelcast-app/README?rev=1162357&view=auto
==============================================================================
--- karaf/cellar/trunk/samples/hazelcast-app/README (added)
+++ karaf/cellar/trunk/samples/hazelcast-app/README Sat Aug 27 14:09:54 2011
@@ -0,0 +1,3 @@
+This samples intend to demostrate how to use the HazelcastInstance created by Cellar.
+
+Mostly it intends to point out that curently Hazelcast requires the user to set the Thread Context ClassLoader, in order to be able to serialize/deserialize user created objects.
Added: karaf/cellar/trunk/samples/hazelcast-app/pom.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/samples/hazelcast-app/pom.xml?rev=1162357&view=auto
==============================================================================
--- karaf/cellar/trunk/samples/hazelcast-app/pom.xml (added)
+++ karaf/cellar/trunk/samples/hazelcast-app/pom.xml Sat Aug 27 14:09:54 2011
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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">
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.apache.karaf.cellar</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.cellar.samples</groupId>
+ <artifactId>hazelcast-app</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Karaf :: Cellar :: Samples :: Hazelcast Application</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <osgi.import>
+ com.hazelcast*,
+ *
+ </osgi.import>
+ <osgi.export>
+ org.apache.karaf.cellar.samples.hazelcast*;version="${project.version}"
+ </osgi.export>
+ <osgi.bundle.activator>org.apache.karaf.cellar.samples.hazelcast.Activator</osgi.bundle.activator>
+ </properties>
+
+ <dependencies>
+ <!-- OSGi Dependencies -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Activator.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Activator.java?rev=1162357&view=auto
==============================================================================
--- karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Activator.java (added)
+++ karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Activator.java Sat Aug 27 14:09:54 2011
@@ -0,0 +1,60 @@
+/*
+ * 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.apache.karaf.cellar.samples.hazelcast;
+
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.core.ITopic;
+import com.hazelcast.core.IdGenerator;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author: iocanel
+ */
+public class Activator implements BundleActivator {
+
+ private static final transient Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+
+ private ITopic topic;
+ private MessageListener messageListener = new MessageListener();
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ ServiceReference reference = context.getServiceReference("com.hazelcast.core.HazelcastInstance");
+ HazelcastInstance instance = (HazelcastInstance) context.getService(reference);
+ context.ungetService(reference);
+ try {
+ IdGenerator idGenerator = instance.getIdGenerator("cellar-smaple-generator");
+ Long id = idGenerator.newId();
+ topic = instance.getTopic("cellar-sample-topic");
+ topic.addMessageListener(messageListener);
+ topic.publish(new Message("id="+id));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ topic.removeMessageListener(messageListener);
+ }
+}
Added: karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Message.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Message.java?rev=1162357&view=auto
==============================================================================
--- karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Message.java (added)
+++ karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/Message.java Sat Aug 27 14:09:54 2011
@@ -0,0 +1,38 @@
+/*
+ * 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.apache.karaf.cellar.samples.hazelcast;
+
+import java.io.Serializable;
+
+/**
+ * @author: iocanel
+ */
+public class Message implements Serializable {
+
+ private final String text;
+
+ /**
+ * Constructor
+ * @param text
+ */
+ public Message(String text) {
+ this.text = text;
+ }
+
+ @Override
+ public String toString() {
+ return "Message[text='"+text+"']";
+ }
+}
Added: karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/MessageListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/MessageListener.java?rev=1162357&view=auto
==============================================================================
--- karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/MessageListener.java (added)
+++ karaf/cellar/trunk/samples/hazelcast-app/src/main/java/org/apache/karaf/cellar/samples/hazelcast/MessageListener.java Sat Aug 27 14:09:54 2011
@@ -0,0 +1,25 @@
+/*
+ * 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.apache.karaf.cellar.samples.hazelcast;
+
+/**
+ * @author: iocanel
+ */
+public class MessageListener implements com.hazelcast.core.MessageListener {
+ @Override
+ public void onMessage(Object message) {
+ System.out.println("Received message:"+message);
+ }
+}
Added: karaf/cellar/trunk/samples/pom.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/samples/pom.xml?rev=1162357&view=auto
==============================================================================
--- karaf/cellar/trunk/samples/pom.xml (added)
+++ karaf/cellar/trunk/samples/pom.xml Sat Aug 27 14:09:54 2011
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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">
+ <parent>
+ <artifactId>cellar</artifactId>
+ <groupId>org.apache.karaf</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.cellar</groupId>
+ <artifactId>samples</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Karaf :: Cellar :: Samples</name>
+
+ <modules>
+ <module>dosgi-greeter</module>
+ <module>hazelcast-app</module>
+ </modules>
+
+</project>
\ No newline at end of file