You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/04/10 16:16:00 UTC

[38/59] [abbrv] [KARAF-2852] Merge package/core and package/command

http://git-wip-us.apache.org/repos/asf/karaf/blob/91232f80/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java b/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java
new file mode 100644
index 0000000..ea8ce1d
--- /dev/null
+++ b/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.packages.core.internal.osgi;
+
+import org.apache.karaf.packages.core.PackageService;
+import org.apache.karaf.packages.core.internal.PackageServiceImpl;
+import org.apache.karaf.packages.core.internal.PackagesMBeanImpl;
+import org.apache.karaf.util.tracker.BaseActivator;
+
+public class Activator extends BaseActivator {
+
+    @Override
+    protected void doStart() throws Exception {
+        PackageService packageService = new PackageServiceImpl(bundleContext);
+        register(PackageService.class, packageService);
+
+        PackagesMBeanImpl mbean = new PackagesMBeanImpl(packageService);
+        registerMBean(mbean, "type=package");
+    }
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/91232f80/package/src/main/resources/OSGI-INF/bundle.info
----------------------------------------------------------------------
diff --git a/package/src/main/resources/OSGI-INF/bundle.info b/package/src/main/resources/OSGI-INF/bundle.info
new file mode 100644
index 0000000..b5747b7
--- /dev/null
+++ b/package/src/main/resources/OSGI-INF/bundle.info
@@ -0,0 +1,15 @@
+h1. Synopsis
+
+${project.name}
+
+${project.description}
+
+Maven URL:
+   [mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+Services for handling packages
+
+h1. See also
+

http://git-wip-us.apache.org/repos/asf/karaf/blob/91232f80/package/src/test/java/org/apache/karaf/packages/core/InstallMBeantest.java
----------------------------------------------------------------------
diff --git a/package/src/test/java/org/apache/karaf/packages/core/InstallMBeantest.java b/package/src/test/java/org/apache/karaf/packages/core/InstallMBeantest.java
new file mode 100644
index 0000000..a9ab11b
--- /dev/null
+++ b/package/src/test/java/org/apache/karaf/packages/core/InstallMBeantest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.packages.core;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.karaf.packages.core.internal.PackagesMBeanImpl;
+import org.junit.Test;
+
+/**
+ * Checks that the PackagesMBean is valid and can be installed in the MBeanServer
+ *
+ */
+public class InstallMBeantest {
+
+    @Test
+    public void test() throws Exception {
+        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+        PackagesMBeanImpl pack = new PackagesMBeanImpl(null);
+        ObjectName oName = new ObjectName("org.apache.karaf:type=package,name=root");
+        server.registerMBean(pack,  oName);
+        server.unregisterMBean(oName);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/91232f80/package/src/test/java/org/apache/karaf/packages/core/PackageRequirementTest.java
----------------------------------------------------------------------
diff --git a/package/src/test/java/org/apache/karaf/packages/core/PackageRequirementTest.java b/package/src/test/java/org/apache/karaf/packages/core/PackageRequirementTest.java
new file mode 100644
index 0000000..2ea1cf8
--- /dev/null
+++ b/package/src/test/java/org/apache/karaf/packages/core/PackageRequirementTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.packages.core;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class PackageRequirementTest {
+
+    @Test
+    public void testGetPackageName() {
+        PackageRequirement req = new PackageRequirement("(&(osgi.wiring.package=org.osgi.service.useradmin)(version>=1.1.0))", false, null, false);
+        String packageName = req.getPackageName();
+        Assert.assertEquals("org.osgi.service.useradmin", packageName);
+    }
+
+}