blob: 238cd5d6f9540174092d2ac478da525ed1c84f5c [file] [log] [blame]
Felix Meschberger819d0b72009-08-14 15:35:27 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.apache.felix.cm.integration.helper;
20
21import java.net.URL;
22import java.util.HashMap;
23import java.util.Map;
24
25import org.ops4j.pax.swissbox.tinybundles.core.BuildableBundle;
26import org.ops4j.pax.swissbox.tinybundles.core.TinyBundle;
27import org.ops4j.pax.swissbox.tinybundles.core.metadata.RawBuilder;
28
29public class MyTinyBundle implements TinyBundle {
30
31 private Map<String, URL> m_resources = new HashMap<String, URL>();
32
33 @SuppressWarnings("unchecked")
34 public TinyBundle addClass( Class clazz )
35 {
36 String name = clazz.getName().replaceAll( "\\.", "/" ) + ".class";
37 addResource( name, clazz.getResource( "/" + name ) );
38 return this;
39 }
40
41 public TinyBundle addResource( String name, URL url )
42 {
43 m_resources.put( name, url );
44 return this;
45 }
46
47 public BuildableBundle prepare( BuildableBundle builder )
48 {
49 return builder.setResources( m_resources );
50 }
51
52 public BuildableBundle prepare()
53 {
54 return new RawBuilder().setResources( m_resources );
55 }
56
57}