001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *   http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    package org.apache.felix.moduleloader;
020    
021    import java.io.IOException;
022    import java.io.InputStream;
023    import java.net.URL;
024    import java.util.Enumeration;
025    import java.util.Map;
026    import org.apache.felix.framework.util.manifestparser.R4Library;
027    import org.osgi.framework.Bundle;
028    import org.osgi.framework.Version;
029    
030    public interface IModule
031    {
032        final static int EAGER_ACTIVATION = 0;
033        final static int LAZY_ACTIVATION = 1;
034    
035        void setSecurityContext(Object securityContext);
036        Object getSecurityContext();
037    
038        // Metadata access methods.
039        Map getHeaders();
040        boolean isExtension();
041        String getSymbolicName();
042        Version getVersion();
043        ICapability[] getCapabilities();
044        IRequirement[] getRequirements();
045        IRequirement[] getDynamicRequirements();
046        R4Library[] getNativeLibraries();
047        int getDeclaredActivationPolicy();
048    
049        // Run-time data access methods.
050        Bundle getBundle();
051        String getId();
052        IWire[] getWires();
053        boolean isResolved();
054    
055        // Content access methods.
056        IContent getContent();
057        Class getClassByDelegation(String name) throws ClassNotFoundException;
058        URL getResourceByDelegation(String name);
059        Enumeration getResourcesByDelegation(String name);
060        URL getEntry(String name);
061    
062        // TODO: ML - For expediency, the index argument was added to these methods
063        // but it is not clear that this makes sense in the long run. This needs to
064        // be readdressed in the future, perhaps by the spec to clearly indicate
065        // how resources on the bundle class path are searched, which is why we
066        // need the index number in the first place -- to differentiate among
067        // resources with the same name on the bundle class path. This was previously
068        // handled as part of the resource path, but that approach is not spec
069        // compliant.
070        boolean hasInputStream(int index, String urlPath)
071            throws IOException;
072        InputStream getInputStream(int index, String urlPath)
073            throws IOException;
074    }