blob: 41ad763207cb49bafe70a8e8c091183bf274b7af [file] [log] [blame]
//
// 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.
//
= DevFaqWhenUseWrapperModule
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqWhenUseWrapperModule
:description: Apache NetBeans wiki DevFaqWhenUseWrapperModule
:toc: left
:toc-title:
:syntax: true
=== When should I use a library wrapper module and when should I just package the library into my module?
The New Module Wizard offers easy support for creating a wrapper module:
*File > New Project > NetBeans Modules > Library Wrapper Module* and since NetBeans 6.8 it is similarly easy to either edit Library Wrapper Module after it has been created or package library directly to your module via *Project Properties > Libraries > Wrapped JARs*.
Before NB 6.8 it was more convenient to create Library Wrapper module due to existence of the wizard, but not Project Properties UI. This biased the answer to this question, but generally there's no harm in using a library wrapper module.
Note that a library wrapper module can wrap more than one external JAR -
you do not need to create one for each library.
But it is a good idea to create a separate wrapper for each JAR
if they come from different projects and might conceivably be used independently.
The general algorithm for making an optimal decision about when to use a wrapper module is this:
* If the library is from some third-party source, and your module is just using it, then
* If it is something very esoteric and your module will be the _only_ module in an installation of NetBeans (or your NetBeans-based app) ever using it
* You are writing only one module that will use the library, _or_ you want to declare the packages contained in your library in the public packages of your module
* If you will never want deliver an update of that library by itself, without delivering an update of your module
* Then you probably just want to package the library directly into your module, as in link:DevFaqModuleDependencies.asciidoc[DevFaqModuleDependencies]
* If you wrote the library you want to use
* You might just want to add the appropriate `OpenIDE-Module-*` entries directly to its manifest and make it a module that way. Remember to list the packages your module will need to export.
* Else, you probably want to read link:DevFaqWrapperModules.asciidoc[DevFaqWrapperModules]
There is a very slight performance penalty to using a wrapper module -
it's one more JAR to open and read from, and one extra layer of indirection for the classloader.
_That is not a reason to avoid using a wrapper module if that's what you need_ -
it really is slight.
In a very large application such as the NetBeans IDE,
such considerations are more important because there are more JARs, more classloaders,
and hence more overhead already.
If you are developing the library yourself, but decide you want to keep the library project separate from any NB module project, you can do so.
See link:DevFaqWrapperModules.asciidoc[Using a wrapper module for an existing project]
for information and various methods to hook them up for
development.
<hr/>
Applies to: NetBeans 6.8 and above
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqWhenUseWrapperModule[http://wiki.netbeans.org/DevFaqWhenUseWrapperModule] ,
that was last modified by NetBeans user Rmichalsky
on 2009-12-02T15:00:34Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.