Taking spring.lookup from http://hg.netbeans.org/main/contrib rev. 37f3159d6571
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/spring.lookup/apichanges.xml Tue Apr 21 21:41:25 2009 +0200
1.3 @@ -0,0 +1,94 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<!--
1.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1.7 +
1.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
1.9 +
1.10 +
1.11 +The contents of this file are subject to the terms of either the GNU
1.12 +General Public License Version 2 only ("GPL") or the Common
1.13 +Development and Distribution License("CDDL") (collectively, the
1.14 +"License"). You may not use this file except in compliance with the
1.15 +License. You can obtain a copy of the License at
1.16 +http://www.netbeans.org/cddl-gplv2.html
1.17 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
1.18 +specific language governing permissions and limitations under the
1.19 +License. When distributing the software, include this License Header
1.20 +Notice in each file and include the License file at
1.21 +nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
1.22 +particular file as subject to the "Classpath" exception as provided
1.23 +by Sun in the GPL Version 2 section of the License file that
1.24 +accompanied this code. If applicable, add the following below the
1.25 +License Header, with the fields enclosed by brackets [] replaced by
1.26 +your own identifying information:
1.27 +"Portions Copyrighted [year] [name of copyright owner]"
1.28 +
1.29 +Contributor(s):
1.30 +
1.31 +The Original Software is NetBeans. The Initial Developer of the Original
1.32 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
1.33 +Microsystems, Inc. All Rights Reserved.
1.34 +
1.35 +If you wish your version of this file to be governed by only the CDDL
1.36 +or only the GPL Version 2, indicate your decision by adding
1.37 +"[Contributor] elects to include this software in this distribution
1.38 +under the [CDDL or GPL Version 2] license." If you do not indicate a
1.39 +single choice of license, a recipient has the option to distribute
1.40 +your version of this file under either the CDDL, the GPL Version 2 or
1.41 +to extend the choice of license to its licensees as provided above.
1.42 +However, if you add GPL Version 2 code and therefore, elected the GPL
1.43 +Version 2 license, then the option applies only if the new code is
1.44 +made subject to such option by the copyright holder.
1.45 +-->
1.46 +
1.47 +<?xml-stylesheet href="../nbbuild/javadoctools/apichanges.xsl" type="text/xsl"?>
1.48 +<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.0//EN" "../../nbbuild/javadoctools/apichanges.dtd">
1.49 +
1.50 +<apichanges>
1.51 +
1.52 +<!-- First, a list of API names you may use: -->
1.53 +<apidefs>
1.54 + <apidef name="spring">Springframework</apidef>
1.55 +</apidefs>
1.56 +
1.57 +<!-- ACTUAL CHANGES BEGIN HERE: -->
1.58 +
1.59 +<changes>
1.60 + <change id="initial.version">
1.61 + <api name="spring"/>
1.62 + <summary>Integration of Spring and NetBeans Started</summary>
1.63 + <version major="1" minor="1"/>
1.64 + <date day="4" month="4" year="2008"/>
1.65 + <author login="jtulach"/>
1.66 + <compatibility addition="yes"/>
1.67 + <description>
1.68 + <p>
1.69 + Initial version of this API.
1.70 + </p>
1.71 + </description>
1.72 + <class package="org.netbeans.api.spring" name="NbSpring"/>
1.73 + </change>
1.74 +</changes>
1.75 +
1.76 + <htmlcontents>
1.77 + <head>
1.78 + <title>NetBeans Spring Bridge</title>
1.79 + <link rel="stylesheet" href="prose.css" type="text/css"/>
1.80 + </head>
1.81 + <body>
1.82 +
1.83 +<p class="overviewlink"><a href="overview-summary.html">Overview</a></p>
1.84 +
1.85 +<h1>Introduction</h1>
1.86 +
1.87 +<p>
1.88 + NetBeans and Springframework integration.
1.89 +</p>
1.90 +
1.91 + <hr/><standard-changelists module-code-name="org.netbeans.api.spring"/>
1.92 +
1.93 + <hr/><p>@FOOTER@</p>
1.94 +
1.95 + </body>
1.96 + </htmlcontents>
1.97 +</apichanges>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/spring.lookup/arch.xml Tue Apr 21 21:41:25 2009 +0200
2.3 @@ -0,0 +1,1088 @@
2.4 +<?xml version="1.0" encoding="UTF-8"?>
2.5 +<!--
2.6 +The contents of this file are subject to the terms of the Common Development
2.7 +and Distribution License (the License). You may not use this file except in
2.8 +compliance with the License.
2.9 +
2.10 +You can obtain a copy of the License at http://www.netbeans.org/cddl.html
2.11 +or http://www.netbeans.org/cddl.txt.
2.12 +
2.13 +When distributing Covered Code, include this CDDL Header Notice in each file
2.14 +and include the License file at http://www.netbeans.org/cddl.txt.
2.15 +If applicable, add the following below the CDDL Header, with the fields
2.16 +enclosed by brackets [] replaced by your own identifying information:
2.17 +"Portions Copyrighted [year] [name of copyright owner]"
2.18 +
2.19 +The Original Software is NetBeans. The Initial Developer of the Original
2.20 +Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
2.21 +Microsystems, Inc. All Rights Reserved.
2.22 +-->
2.23 +<!DOCTYPE api-answers PUBLIC "-//NetBeans//DTD Arch Answers//EN" "../../nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd" [
2.24 + <!ENTITY api-questions SYSTEM "../../nbbuild/antsrc/org/netbeans/nbbuild/Arch-api-questions.xml">
2.25 +]>
2.26 +
2.27 +<api-answers
2.28 + question-version="1.29"
2.29 + author="yourname@netbeans.org"
2.30 +>
2.31 +
2.32 + &api-questions;
2.33 +
2.34 +
2.35 +<!--
2.36 + <question id="arch-overall" when="init">
2.37 + Describe the overall architecture.
2.38 + <hint>
2.39 + What will be API for
2.40 + <a href="http://openide.netbeans.org/tutorial/api-design.html#design.apiandspi">
2.41 + clients and what support API</a>?
2.42 + What parts will be pluggable?
2.43 + How will plug-ins be registered? Please use <code><api type="export"/></code>
2.44 + to describe your general APIs and specify their
2.45 + <a href="http://openide.netbeans.org/tutorial/api-design.html#category-private">
2.46 + stability categories</a>.
2.47 + If possible please provide simple diagrams.
2.48 + </hint>
2.49 + </question>
2.50 +-->
2.51 + <answer id="arch-overall">
2.52 + <p>
2.53 + Lookup and the Springframework's injection mechanism seem to be quite
2.54 + similar. This module is here to create a bridge between these two.
2.55 + </p>
2.56 + </answer>
2.57 +
2.58 +
2.59 +
2.60 +<!--
2.61 + <question id="arch-quality" when="init">
2.62 + How will the <a href="http://www.netbeans.org/community/guidelines/q-evangelism.html">quality</a>
2.63 + of your code be tested and
2.64 + how are future regressions going to be prevented?
2.65 + <hint>
2.66 + What kind of testing do
2.67 + you want to use? How much functionality, in which areas,
2.68 + should be covered by the tests? How you find out that your
2.69 + project was successful?
2.70 + </hint>
2.71 + </question>
2.72 +-->
2.73 + <answer id="arch-quality">
2.74 + <p>
2.75 + Unit tests.
2.76 + </p>
2.77 + </answer>
2.78 +
2.79 +
2.80 +
2.81 + <answer id="arch-time">
2.82 + <p>
2.83 + Initial version ready in 2008, more enhance features per request and contribution.
2.84 + </p>
2.85 + </answer>
2.86 +
2.87 +
2.88 +
2.89 +<!--
2.90 + <question id="arch-usecases" when="init">
2.91 + <hint>
2.92 + Content of this answer will be displayed as part of page at
2.93 + http://www.netbeans.org/download/dev/javadoc/usecases.html
2.94 + You can use tags <usecase name="name> regular html description </usecase>
2.95 + and if you want to use an URL you can prefix if with @TOP@ to begin
2.96 + at the root of your javadoc
2.97 + </hint>
2.98 +
2.99 + Describe the main <a href="http://openide.netbeans.org/tutorial/api-design.html#usecase">
2.100 + use cases</a> of the new API. Who will use it under
2.101 + what circumstances? What kind of code would typically need to be written
2.102 + to use the module?
2.103 + </question>
2.104 +-->
2.105 + <answer id="arch-usecases">
2.106 + <p>
2.107 + XXX no answer for arch-usecases
2.108 + </p>
2.109 + </answer>
2.110 +
2.111 +
2.112 +
2.113 +<!--
2.114 + <question id="arch-what" when="init">
2.115 + What is this project good for?
2.116 + <hint>
2.117 + Please provide here a few lines describing the project,
2.118 + what problem it should solve, provide links to documentation,
2.119 + specifications, etc.
2.120 + </hint>
2.121 + </question>
2.122 +-->
2.123 + <answer id="arch-what">
2.124 + <p>
2.125 + <api name="org.netbeans.api.spring" category="official" group="java" type="export"
2.126 + url="@TOP@/org/netbeans/api/spring/package-summary.html"
2.127 + >
2.128 + API for bridging Springframework injection mechanism and Lookup
2.129 + </api>
2.130 + </p>
2.131 + </answer>
2.132 +
2.133 +
2.134 +
2.135 +<!--
2.136 + <question id="arch-where" when="impl">
2.137 + Where one can find sources for your module?
2.138 + <hint>
2.139 + Please provide link to the Hg web client at
2.140 + http://hg.netbeans.org/
2.141 + or just use tag defaultanswer generate='here'
2.142 + </hint>
2.143 + </question>
2.144 +-->
2.145 + <answer id="arch-where">
2.146 + <defaultanswer generate='here' />
2.147 + </answer>
2.148 +
2.149 +
2.150 +
2.151 +<!--
2.152 + <question id="compat-deprecation" when="init">
2.153 + How the introduction of your project influences functionality
2.154 + provided by previous version of the product?
2.155 + <hint>
2.156 + If you are planning to deprecate/remove/change any existing APIs,
2.157 + list them here accompanied with the reason explaining why you
2.158 + are doing so.
2.159 + </hint>
2.160 + </question>
2.161 +-->
2.162 + <answer id="compat-deprecation">
2.163 + <p>
2.164 + XXX no answer for compat-deprecation
2.165 + </p>
2.166 + </answer>
2.167 +
2.168 +
2.169 +
2.170 +<!--
2.171 + <question id="compat-i18n" when="impl">
2.172 + Is your module correctly internationalized?
2.173 + <hint>
2.174 + Correct internationalization means that it obeys instructions
2.175 + at <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/i18n-branding.html">
2.176 + NetBeans I18N pages</a>.
2.177 + </hint>
2.178 + </question>
2.179 +-->
2.180 + <answer id="compat-i18n">
2.181 + <p>
2.182 + XXX no answer for compat-i18n
2.183 + </p>
2.184 + </answer>
2.185 +
2.186 +
2.187 +
2.188 +<!--
2.189 + <question id="compat-standards" when="init">
2.190 + Does the module implement or define any standards? Is the
2.191 + implementation exact or does it deviate somehow?
2.192 + </question>
2.193 +-->
2.194 + <answer id="compat-standards">
2.195 + <p>
2.196 + XXX no answer for compat-standards
2.197 + </p>
2.198 + </answer>
2.199 +
2.200 +
2.201 +
2.202 +<!--
2.203 + <question id="compat-version" when="impl">
2.204 + Can your module coexist with earlier and future
2.205 + versions of itself? Can you correctly read all old settings? Will future
2.206 + versions be able to read your current settings? Can you read
2.207 + or politely ignore settings stored by a future version?
2.208 +
2.209 + <hint>
2.210 + Very helpful for reading settings is to store version number
2.211 + there, so future versions can decide whether how to read/convert
2.212 + the settings and older versions can ignore the new ones.
2.213 + </hint>
2.214 + </question>
2.215 +-->
2.216 + <answer id="compat-version">
2.217 + <p>
2.218 + XXX no answer for compat-version
2.219 + </p>
2.220 + </answer>
2.221 +
2.222 +
2.223 +
2.224 +<!--
2.225 + <question id="dep-jre" when="final">
2.226 + Which version of JRE do you need (1.2, 1.3, 1.4, etc.)?
2.227 + <hint>
2.228 + It is expected that if your module runs on 1.x that it will run
2.229 + on 1.x+1 if no, state that please. Also describe here cases where
2.230 + you run different code on different versions of JRE and why.
2.231 + </hint>
2.232 + </question>
2.233 +-->
2.234 + <answer id="dep-jre">
2.235 + <p>
2.236 + XXX no answer for dep-jre
2.237 + </p>
2.238 + </answer>
2.239 +
2.240 +
2.241 +
2.242 +<!--
2.243 + <question id="dep-jrejdk" when="final">
2.244 + Do you require the JDK or is the JRE enough?
2.245 + </question>
2.246 +-->
2.247 + <answer id="dep-jrejdk">
2.248 + <p>
2.249 + XXX no answer for dep-jrejdk
2.250 + </p>
2.251 + </answer>
2.252 +
2.253 +
2.254 +
2.255 +<!--
2.256 + <question id="dep-nb" when="init">
2.257 + What other NetBeans projects and modules does this one depend on?
2.258 + <hint>
2.259 + Depending on other NetBeans projects influnces the ability of
2.260 + users of your work to customize their own branded version of
2.261 + NetBeans by enabling and disabling some modules. Too
2.262 + much dependencies restrict this kind of customization. If that
2.263 + is your case, then you may want to split your functionality into
2.264 + pieces of autoload, eager and regular modules which can be
2.265 + enabled independently. Usually the answer to this question
2.266 + is generated from your <code>project.xml</code> file, but
2.267 + if it is not guessed correctly, you can suppress it by
2.268 + specifying <defaultanswer generate="none"/> and
2.269 + write here your own. Please describe such projects as imported APIs using
2.270 + the <code><api name="identification" type="import or export" category="stable" url="where is the description" /></code>.
2.271 + By doing this information gets listed in the summary page of your
2.272 + javadoc.
2.273 + </hint>
2.274 + </question>
2.275 +-->
2.276 + <answer id="dep-nb">
2.277 + <defaultanswer generate='here' />
2.278 + </answer>
2.279 +
2.280 +
2.281 +
2.282 +<!--
2.283 + <question id="dep-non-nb" when="init">
2.284 + What other projects outside NetBeans does this one depend on?
2.285 +
2.286 + <hint>
2.287 + Depending on 3rd party libraries is always problematic,
2.288 + especially if they are not open source, as that complicates
2.289 + the licensing scheme of NetBeans. Please enumerate your
2.290 + external dependencies here, so it is correctly understood since
2.291 + the begining what are the legal implications of your project.
2.292 + Also please note that
2.293 + some non-NetBeans projects are packaged as NetBeans modules
2.294 + (see <a href="http://libs.netbeans.org/">libraries</a>) and
2.295 + it is preferred to use this approach when more modules may
2.296 + depend and share such third-party libraries.
2.297 + </hint>
2.298 + </question>
2.299 +-->
2.300 + <answer id="dep-non-nb">
2.301 + <p>
2.302 + XXX no answer for dep-non-nb
2.303 + </p>
2.304 + </answer>
2.305 +
2.306 +
2.307 +
2.308 +<!--
2.309 + <question id="dep-platform" when="init">
2.310 + On which platforms does your module run? Does it run in the same
2.311 + way on each?
2.312 + <hint>
2.313 + If you plan any dependency on OS or any usage of native code,
2.314 + please describe why you are doing so and describe how you envision
2.315 + to enforce the portability of your code.
2.316 + Please note that there is a support for <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#how-os-specific">OS conditionally
2.317 + enabled modules</a> which together with autoload/eager modules
2.318 + can allow you to enable to provide the best OS aware support
2.319 + on certain OSes while providing compatibility bridge on the not
2.320 + supported ones.
2.321 + Also please list the supported
2.322 + OSes/HW platforms and mentioned the lovest version of JDK required
2.323 + for your project to run on. Also state whether JRE is enough or
2.324 + you really need JDK.
2.325 + </hint>
2.326 + </question>
2.327 +-->
2.328 + <answer id="dep-platform">
2.329 + <p>
2.330 + XXX no answer for dep-platform
2.331 + </p>
2.332 + </answer>
2.333 +
2.334 +
2.335 +
2.336 +<!--
2.337 + <question id="deploy-dependencies" when="final">
2.338 + What do other modules need to do to declare a dependency on this one,
2.339 + in addition to or instead of the normal module dependency declaration
2.340 + (e.g. tokens to require)?
2.341 + <hint>
2.342 + Provide a sample of the actual lines you would add to a module manifest
2.343 + to declare a dependency, for example OpenIDE-Module-Requires: some.token.
2.344 + If other modules should not depend on this module, or should just use a
2.345 + simple regular module dependency, you can just answer "nothing". If you
2.346 + intentionally expose a semistable API to clients using implementation
2.347 + dependencies, you should mention that here (but there is no need to give
2.348 + an example of usage).
2.349 + </hint>
2.350 + </question>
2.351 +-->
2.352 + <answer id="deploy-dependencies">
2.353 + <p>
2.354 + XXX no answer for deploy-dependencies
2.355 + </p>
2.356 + </answer>
2.357 +
2.358 +
2.359 +
2.360 +<!--
2.361 + <question id="deploy-jar" when="impl">
2.362 + Do you deploy just module JAR file(s) or other files as well?
2.363 + <hint>
2.364 + Usually a module consist of one JAR file (perhaps with Class-Path
2.365 + extensions) and also a configuration file that enables it. If you
2.366 + have any other files, use
2.367 + <api group="java.io.File" name="yourname" type="export" category="friend">...</api>
2.368 + to define the location, name and stability of your files (of course
2.369 + changing "yourname" and "friend" to suit your needs).
2.370 +
2.371 + If it uses more than one JAR, describe where they are located, how
2.372 + they refer to each other.
2.373 + If it consist of module JAR(s) and other files, please describe
2.374 + what is their purpose, why other files are necessary. Please
2.375 + make sure that installation/uninstallation leaves the system
2.376 + in state as it was before installation.
2.377 + </hint>
2.378 + </question>
2.379 +-->
2.380 + <answer id="deploy-jar">
2.381 + <p>
2.382 + XXX no answer for deploy-jar
2.383 + </p>
2.384 + </answer>
2.385 +
2.386 +
2.387 +
2.388 +<!--
2.389 + <question id="deploy-nbm" when="impl">
2.390 + Can you deploy an NBM via the Update Center?
2.391 + <hint>
2.392 + If not why?
2.393 + </hint>
2.394 + </question>
2.395 +-->
2.396 + <answer id="deploy-nbm">
2.397 + <p>
2.398 + XXX no answer for deploy-nbm
2.399 + </p>
2.400 + </answer>
2.401 +
2.402 +
2.403 +
2.404 +<!--
2.405 + <question id="deploy-packages" when="init">
2.406 + Are packages of your module made inaccessible by not declaring them
2.407 + public?
2.408 +
2.409 + <hint>
2.410 + By default NetBeans build harness treats all packages are private.
2.411 + If you export some of them - either as public or friend packages,
2.412 + you should have a reason. If the reason is described elsewhere
2.413 + in this document, you can ignore this question.
2.414 + </hint>
2.415 + </question>
2.416 +-->
2.417 + <answer id="deploy-packages">
2.418 + <p>
2.419 + XXX no answer for deploy-packages
2.420 + </p>
2.421 + </answer>
2.422 +
2.423 +
2.424 +
2.425 +<!--
2.426 + <question id="deploy-shared" when="final">
2.427 + Do you need to be installed in the shared location only, or in the user directory only,
2.428 + or can your module be installed anywhere?
2.429 + <hint>
2.430 + Installation location shall not matter, if it does explain why.
2.431 + Consider also whether <code>InstalledFileLocator</code> can help.
2.432 + </hint>
2.433 + </question>
2.434 +-->
2.435 + <answer id="deploy-shared">
2.436 + <p>
2.437 + XXX no answer for deploy-shared
2.438 + </p>
2.439 + </answer>
2.440 +
2.441 +
2.442 +
2.443 +<!--
2.444 + <question id="exec-ant-tasks" when="impl">
2.445 + Do you define or register any ant tasks that other can use?
2.446 +
2.447 + <hint>
2.448 + If you provide an ant task that users can use, you need to be very
2.449 + careful about its syntax and behaviour, as it most likely forms an
2.450 + API for end users and as there is a lot of end users, their reaction
2.451 + when such API gets broken can be pretty strong.
2.452 + </hint>
2.453 + </question>
2.454 +-->
2.455 + <answer id="exec-ant-tasks">
2.456 + <p>
2.457 + XXX no answer for exec-ant-tasks
2.458 + </p>
2.459 + </answer>
2.460 +
2.461 +
2.462 +
2.463 +<!--
2.464 + <question id="exec-classloader" when="impl">
2.465 + Does your code create its own class loader(s)?
2.466 + <hint>
2.467 + A bit unusual. Please explain why and what for.
2.468 + </hint>
2.469 + </question>
2.470 +-->
2.471 + <answer id="exec-classloader">
2.472 + <p>
2.473 + XXX no answer for exec-classloader
2.474 + </p>
2.475 + </answer>
2.476 +
2.477 +
2.478 +
2.479 +<!--
2.480 + <question id="exec-component" when="impl">
2.481 + Is execution of your code influenced by any (string) property
2.482 + of any of your components?
2.483 +
2.484 + <hint>
2.485 + Often <code>JComponent.getClientProperty</code>, <code>Action.getValue</code>
2.486 + or <code>PropertyDescriptor.getValue</code>, etc. are used to influence
2.487 + a behavior of some code. This of course forms an interface that should
2.488 + be documented. Also if one depends on some interface that an object
2.489 + implements (<code>component instanceof Runnable</code>) that forms an
2.490 + API as well.
2.491 + </hint>
2.492 + </question>
2.493 +-->
2.494 + <answer id="exec-component">
2.495 + <p>
2.496 + XXX no answer for exec-component
2.497 + </p>
2.498 + </answer>
2.499 +
2.500 +
2.501 +
2.502 +<!--
2.503 + <question id="exec-introspection" when="impl">
2.504 + Does your module use any kind of runtime type information (<code>instanceof</code>,
2.505 + work with <code>java.lang.Class</code>, etc.)?
2.506 + <hint>
2.507 + Check for cases when you have an object of type A and you also
2.508 + expect it to (possibly) be of type B and do some special action. That
2.509 + should be documented. The same applies on operations in meta-level
2.510 + (Class.isInstance(...), Class.isAssignableFrom(...), etc.).
2.511 + </hint>
2.512 + </question>
2.513 +-->
2.514 + <answer id="exec-introspection">
2.515 + <p>
2.516 + XXX no answer for exec-introspection
2.517 + </p>
2.518 + </answer>
2.519 +
2.520 +
2.521 +
2.522 +<!--
2.523 + <question id="exec-privateaccess" when="final">
2.524 + Are you aware of any other parts of the system calling some of
2.525 + your methods by reflection?
2.526 + <hint>
2.527 + If so, describe the "contract" as an API. Likely private or friend one, but
2.528 + still API and consider rewrite of it.
2.529 + </hint>
2.530 + </question>
2.531 +-->
2.532 + <answer id="exec-privateaccess">
2.533 + <p>
2.534 + XXX no answer for exec-privateaccess
2.535 + </p>
2.536 + </answer>
2.537 +
2.538 +
2.539 +
2.540 +<!--
2.541 + <question id="exec-process" when="impl">
2.542 + Do you execute an external process from your module? How do you ensure
2.543 + that the result is the same on different platforms? Do you parse output?
2.544 + Do you depend on result code?
2.545 + <hint>
2.546 + If you feed an input, parse the output please declare that as an API.
2.547 + </hint>
2.548 + </question>
2.549 +-->
2.550 + <answer id="exec-process">
2.551 + <p>
2.552 + XXX no answer for exec-process
2.553 + </p>
2.554 + </answer>
2.555 +
2.556 +
2.557 +
2.558 +<!--
2.559 + <question id="exec-property" when="impl">
2.560 + Is execution of your code influenced by any environment or
2.561 + Java system (<code>System.getProperty</code>) property?
2.562 + On a similar note, is there something interesting that you
2.563 + pass to <code>java.util.logging.Logger</code>? Or do you observe
2.564 + what others log?
2.565 + <hint>
2.566 + If there is a property that can change the behavior of your
2.567 + code, somebody will likely use it. You should describe what it does
2.568 + and the <a href="http://openide.netbeans.org/tutorial/api-design.html#life">stability category</a>
2.569 + of this API. You may use
2.570 + <pre>
2.571 + <api type="export" group="property" name="id" category="private" url="http://...">
2.572 + description of the property, where it is used, what it influence, etc.
2.573 + </api>
2.574 + </pre>
2.575 + </hint>
2.576 + </question>
2.577 +-->
2.578 + <answer id="exec-property">
2.579 + <p>
2.580 + XXX no answer for exec-property
2.581 + </p>
2.582 + </answer>
2.583 +
2.584 +
2.585 +
2.586 +<!--
2.587 + <question id="exec-reflection" when="impl">
2.588 + Does your code use Java Reflection to execute other code?
2.589 + <hint>
2.590 + This usually indicates a missing or insufficient API in the other
2.591 + part of the system. If the other side is not aware of your dependency
2.592 + this contract can be easily broken.
2.593 + </hint>
2.594 + </question>
2.595 +-->
2.596 + <answer id="exec-reflection">
2.597 + <p>
2.598 + XXX no answer for exec-reflection
2.599 + </p>
2.600 + </answer>
2.601 +
2.602 +
2.603 +
2.604 +<!--
2.605 + <question id="exec-threading" when="init">
2.606 + What threading models, if any, does your module adhere to? How the
2.607 + project behaves with respect to threading?
2.608 + <hint>
2.609 + Is your API threadsafe? Can it be accessed from any threads or
2.610 + just from some dedicated ones? Any special relation to AWT and
2.611 + its Event Dispatch thread? Also
2.612 + if your module calls foreign APIs which have a specific threading model,
2.613 + indicate how you comply with the requirements for multithreaded access
2.614 + (synchronization, mutexes, etc.) applicable to those APIs.
2.615 + If your module defines any APIs, or has complex internal structures
2.616 + that might be used from multiple threads, declare how you protect
2.617 + data against concurrent access, race conditions, deadlocks, etc.,
2.618 + and whether such rules are enforced by runtime warnings, errors, assertions, etc.
2.619 + Examples: a class might be non-thread-safe (like Java Collections); might
2.620 + be fully thread-safe (internal locking); might require access through a mutex
2.621 + (and may or may not automatically acquire that mutex on behalf of a client method);
2.622 + might be able to run only in the event queue; etc.
2.623 + Also describe when any events are fired: synchronously, asynchronously, etc.
2.624 + Ideas: <a href="http://core.netbeans.org/proposals/threading/index.html#recommendations">Threading Recommendations</a> (in progress)
2.625 + </hint>
2.626 + </question>
2.627 +-->
2.628 + <answer id="exec-threading">
2.629 + <p>
2.630 + XXX no answer for exec-threading
2.631 + </p>
2.632 + </answer>
2.633 +
2.634 +
2.635 +
2.636 +<!--
2.637 + <question id="format-clipboard" when="impl">
2.638 + Which data flavors (if any) does your code read from or insert to
2.639 + the clipboard (by access to clipboard on means calling methods on <code>java.awt.datatransfer.Transferable</code>?
2.640 +
2.641 + <hint>
2.642 + Often Node's deal with clipboard by usage of <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
2.643 + Check your code for overriding these methods.
2.644 + </hint>
2.645 + </question>
2.646 +-->
2.647 + <answer id="format-clipboard">
2.648 + <p>
2.649 + XXX no answer for format-clipboard
2.650 + </p>
2.651 + </answer>
2.652 +
2.653 +
2.654 +
2.655 +<!--
2.656 + <question id="format-dnd" when="impl">
2.657 + Which protocols (if any) does your code understand during Drag & Drop?
2.658 + <hint>
2.659 + Often Node's deal with clipboard by usage of <code>Node.drag, Node.getDropType</code>.
2.660 + Check your code for overriding these methods. Btw. if they are not overridden, they
2.661 + by default delegate to <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
2.662 + </hint>
2.663 + </question>
2.664 +-->
2.665 + <answer id="format-dnd">
2.666 + <p>
2.667 + XXX no answer for format-dnd
2.668 + </p>
2.669 + </answer>
2.670 +
2.671 +
2.672 +
2.673 +<!--
2.674 + <question id="format-types" when="impl">
2.675 + Which protocols and file formats (if any) does your module read or write on disk,
2.676 + or transmit or receive over the network? Do you generate an ant build script?
2.677 + Can it be edited and modified?
2.678 +
2.679 + <hint>
2.680 + <p>
2.681 + Files can be read and written by other programs, modules and users. If they influence
2.682 + your behaviour, make sure you either document the format or claim that it is a private
2.683 + api (using the <api> tag).
2.684 + </p>
2.685 +
2.686 + <p>
2.687 + If you generate an ant build file, this is very likely going to be seen by end users and
2.688 + they will be attempted to edit it. You should be ready for that and provide here a link
2.689 + to documentation that you have for such purposes and also describe how you are going to
2.690 + understand such files during next release, when you (very likely) slightly change the
2.691 + format.
2.692 + </p>
2.693 + </hint>
2.694 + </question>
2.695 +-->
2.696 + <answer id="format-types">
2.697 + <p>
2.698 + XXX no answer for format-types
2.699 + </p>
2.700 + </answer>
2.701 +
2.702 +
2.703 +
2.704 +<!--
2.705 + <question id="lookup-lookup" when="init">
2.706 + Does your module use <code>org.openide.util.Lookup</code>
2.707 + or any similar technology to find any components to communicate with? Which ones?
2.708 +
2.709 + <hint>
2.710 + NetBeans is build around a generic registry of services called
2.711 + lookup. It is preferable to use it for registration and discovery
2.712 + if possible. See
2.713 + <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-util/org/openide/util/lookup/doc-files/index.html">
2.714 + The Solution to Comunication Between Components
2.715 + </a>. If you do not plan to use lookup and insist usage
2.716 + of other solution, then please describe why it is not working for
2.717 + you.
2.718 + <br/>
2.719 + When filling the final version of your arch document, please
2.720 + describe the interfaces you are searching for, where
2.721 + are defined, whether you are searching for just one or more of them,
2.722 + if the order is important, etc. Also classify the stability of such
2.723 + API contract. Use <api group=&lookup& /> tag, so
2.724 + your information gets listed in the summary page of your javadoc.
2.725 + </hint>
2.726 + </question>
2.727 +-->
2.728 + <answer id="lookup-lookup">
2.729 + <p>
2.730 + XXX no answer for lookup-lookup
2.731 + </p>
2.732 + </answer>
2.733 +
2.734 +
2.735 +
2.736 +<!--
2.737 + <question id="lookup-register" when="final">
2.738 + Do you register anything into lookup for other code to find?
2.739 + <hint>
2.740 + Do you register using layer file or using <code>META-INF/services</code>?
2.741 + Who is supposed to find your component?
2.742 + </hint>
2.743 + </question>
2.744 +-->
2.745 + <answer id="lookup-register">
2.746 + <p>
2.747 + XXX no answer for lookup-register
2.748 + </p>
2.749 + </answer>
2.750 +
2.751 +
2.752 +
2.753 +<!--
2.754 + <question id="lookup-remove" when="final">
2.755 + Do you remove entries of other modules from lookup?
2.756 + <hint>
2.757 + Why? Of course, that is possible, but it can be dangerous. Is the module
2.758 + your are masking resource from aware of what you are doing?
2.759 + </hint>
2.760 + </question>
2.761 +-->
2.762 + <answer id="lookup-remove">
2.763 + <p>
2.764 + XXX no answer for lookup-remove
2.765 + </p>
2.766 + </answer>
2.767 +
2.768 +
2.769 +
2.770 +<!--
2.771 + <question id="perf-exit" when="final">
2.772 + Does your module run any code on exit?
2.773 + </question>
2.774 +-->
2.775 + <answer id="perf-exit">
2.776 + <p>
2.777 + XXX no answer for perf-exit
2.778 + </p>
2.779 + </answer>
2.780 +
2.781 +
2.782 +
2.783 +<!--
2.784 + <question id="perf-huge_dialogs" when="final">
2.785 + Does your module contain any dialogs or wizards with a large number of
2.786 + GUI controls such as combo boxes, lists, trees, or text areas?
2.787 + </question>
2.788 +-->
2.789 + <answer id="perf-huge_dialogs">
2.790 + <p>
2.791 + XXX no answer for perf-huge_dialogs
2.792 + </p>
2.793 + </answer>
2.794 +
2.795 +
2.796 +
2.797 +<!--
2.798 + <question id="perf-limit" when="init">
2.799 + Are there any hard-coded or practical limits in the number or size of
2.800 + elements your code can handle?
2.801 + <hint>
2.802 + Most of algorithms have increasing memory and speed complexity
2.803 + with respect to size of data they operate on. What is the critical
2.804 + part of your project that can be seen as a bottleneck with
2.805 + respect to speed or required memory? What are the practical
2.806 + sizes of data you tested your project with? What is your estimate
2.807 + of potential size of data that would cause visible performance
2.808 + problems? Is there some kind of check to detect such situation
2.809 + and prevent "hard" crashes - for example the CloneableEditorSupport
2.810 + checks for size of a file to be opened in editor
2.811 + and if it is larger than 1Mb it shows a dialog giving the
2.812 + user the right to decide - e.g. to cancel or commit suicide.
2.813 + </hint>
2.814 + </question>
2.815 +-->
2.816 + <answer id="perf-limit">
2.817 + <p>
2.818 + XXX no answer for perf-limit
2.819 + </p>
2.820 + </answer>
2.821 +
2.822 +
2.823 +
2.824 +<!--
2.825 + <question id="perf-mem" when="final">
2.826 + How much memory does your component consume? Estimate
2.827 + with a relation to the number of windows, etc.
2.828 + </question>
2.829 +-->
2.830 + <answer id="perf-mem">
2.831 + <p>
2.832 + XXX no answer for perf-mem
2.833 + </p>
2.834 + </answer>
2.835 +
2.836 +
2.837 +
2.838 +<!--
2.839 + <question id="perf-menus" when="final">
2.840 + Does your module use dynamically updated context menus, or
2.841 + context-sensitive actions with complicated and slow enablement logic?
2.842 + <hint>
2.843 + If you do a lot of tricks when adding actions to regular or context menus, you can significantly
2.844 + slow down display of the menu, even when the user is not using your action. Pay attention to
2.845 + actions you add to the main menu bar, and to context menus of foreign nodes or components. If
2.846 + the action is conditionally enabled, or changes its display dynamically, you need to check the
2.847 + impact on performance. In some cases it may be more appropriate to make a simple action that is
2.848 + always enabled but does more detailed checks in a dialog if it is actually run.
2.849 + </hint>
2.850 + </question>
2.851 +-->
2.852 + <answer id="perf-menus">
2.853 + <p>
2.854 + XXX no answer for perf-menus
2.855 + </p>
2.856 + </answer>
2.857 +
2.858 +
2.859 +
2.860 +<!--
2.861 + <question id="perf-progress" when="final">
2.862 + Does your module execute any long-running tasks?
2.863 +
2.864 + <hint>Long running tasks should never block
2.865 + AWT thread as it badly hurts the UI
2.866 + <a href="http://performance.netbeans.org/responsiveness/issues.html">
2.867 + responsiveness</a>.
2.868 + Tasks like connecting over
2.869 + network, computing huge amount of data, compilation
2.870 + be done asynchronously (for example
2.871 + using <code>RequestProcessor</code>), definitively it should
2.872 + not block AWT thread.
2.873 + </hint>
2.874 + </question>
2.875 +-->
2.876 + <answer id="perf-progress">
2.877 + <p>
2.878 + XXX no answer for perf-progress
2.879 + </p>
2.880 + </answer>
2.881 +
2.882 +
2.883 +
2.884 +<!--
2.885 + <question id="perf-scale" when="init">
2.886 + Which external criteria influence the performance of your
2.887 + program (size of file in editor, number of files in menu,
2.888 + in source directory, etc.) and how well your code scales?
2.889 + <hint>
2.890 + Please include some estimates, there are other more detailed
2.891 + questions to answer in later phases of implementation.
2.892 + </hint>
2.893 + </question>
2.894 +-->
2.895 + <answer id="perf-scale">
2.896 + <p>
2.897 + XXX no answer for perf-scale
2.898 + </p>
2.899 + </answer>
2.900 +
2.901 +
2.902 +
2.903 +<!--
2.904 + <question id="perf-spi" when="init">
2.905 + How the performance of the plugged in code will be enforced?
2.906 + <hint>
2.907 + If you allow foreign code to be plugged into your own module, how
2.908 + do you enforce that it will behave correctly and quickly and will not
2.909 + negatively influence the performance of your own module?
2.910 + </hint>
2.911 + </question>
2.912 +-->
2.913 + <answer id="perf-spi">
2.914 + <p>
2.915 + XXX no answer for perf-spi
2.916 + </p>
2.917 + </answer>
2.918 +
2.919 +
2.920 +
2.921 +<!--
2.922 + <question id="perf-startup" when="final">
2.923 + Does your module run any code on startup?
2.924 + </question>
2.925 +-->
2.926 + <answer id="perf-startup">
2.927 + <p>
2.928 + XXX no answer for perf-startup
2.929 + </p>
2.930 + </answer>
2.931 +
2.932 +
2.933 +
2.934 +<!--
2.935 + <question id="perf-wakeup" when="final">
2.936 + Does any piece of your code wake up periodically and do something
2.937 + even when the system is otherwise idle (no user interaction)?
2.938 + </question>
2.939 +-->
2.940 + <answer id="perf-wakeup">
2.941 + <p>
2.942 + XXX no answer for perf-wakeup
2.943 + </p>
2.944 + </answer>
2.945 +
2.946 +
2.947 +
2.948 +<!--
2.949 + <question id="resources-file" when="final">
2.950 + Does your module use <code>java.io.File</code> directly?
2.951 +
2.952 + <hint>
2.953 + NetBeans provide a logical wrapper over plain files called
2.954 + <code>org.openide.filesystems.FileObject</code> that
2.955 + provides uniform access to such resources and is the preferred
2.956 + way that should be used. But of course there can be situations when
2.957 + this is not suitable.
2.958 + </hint>
2.959 + </question>
2.960 +-->
2.961 + <answer id="resources-file">
2.962 + <p>
2.963 + XXX no answer for resources-file
2.964 + </p>
2.965 + </answer>
2.966 +
2.967 +
2.968 +
2.969 +<!--
2.970 + <question id="resources-layer" when="final">
2.971 + Does your module provide own layer? Does it create any files or
2.972 + folders in it? What it is trying to communicate by that and with which
2.973 + components?
2.974 +
2.975 + <hint>
2.976 + NetBeans allows automatic and declarative installation of resources
2.977 + by module layers. Module register files into appropriate places
2.978 + and other components use that information to perform their task
2.979 + (build menu, toolbar, window layout, list of templates, set of
2.980 + options, etc.).
2.981 + </hint>
2.982 + </question>
2.983 +-->
2.984 + <answer id="resources-layer">
2.985 + <p>
2.986 + XXX no answer for resources-layer
2.987 + </p>
2.988 + </answer>
2.989 +
2.990 +
2.991 +
2.992 +<!--
2.993 + <question id="resources-mask" when="final">
2.994 + Does your module mask/hide/override any resources provided by other modules in
2.995 + their layers?
2.996 +
2.997 + <hint>
2.998 + If you mask a file provided by another module, you probably depend
2.999 + on that and do not want the other module to (for example) change
2.1000 + the file's name. That module shall thus make that file available as an API
2.1001 + of some stability category.
2.1002 + </hint>
2.1003 + </question>
2.1004 +-->
2.1005 + <answer id="resources-mask">
2.1006 + <p>
2.1007 + XXX no answer for resources-mask
2.1008 + </p>
2.1009 + </answer>
2.1010 +
2.1011 +
2.1012 +
2.1013 +<!--
2.1014 + <question id="resources-preferences" when="final">
2.1015 + Does your module uses preferences via Preferences API? Does your module use NbPreferences or
2.1016 + or regular JDK Preferences ? Does it read, write or both ?
2.1017 + Does it share preferences with other modules ? If so, then why ?
2.1018 + <hint>
2.1019 + You may use
2.1020 + <api type="export" group="preferences"
2.1021 + name="preference node name" category="private">
2.1022 + description of individual keys, where it is used, what it
2.1023 + influences, whether the module reads/write it, etc.
2.1024 + </api>
2.1025 + Due to XML ID restrictions, rather than /org/netbeans/modules/foo give the "name" as org.netbeans.modules.foo.
2.1026 + Note that if you use NbPreferences this name will then be the same as the code name base of the module.
2.1027 + </hint>
2.1028 + </question>
2.1029 +-->
2.1030 + <answer id="resources-preferences">
2.1031 + <p>
2.1032 + XXX no answer for resources-preferences
2.1033 + </p>
2.1034 + </answer>
2.1035 +
2.1036 +
2.1037 +
2.1038 +<!--
2.1039 + <question id="resources-read" when="final">
2.1040 + Does your module read any resources from layers? For what purpose?
2.1041 +
2.1042 + <hint>
2.1043 + As this is some kind of intermodule dependency, it is a kind of API.
2.1044 + Please describe it and classify according to
2.1045 + <a href="http://openide.netbeans.org/tutorial/api-design.html#categories">
2.1046 + common stability categories</a>.
2.1047 + </hint>
2.1048 + </question>
2.1049 +-->
2.1050 + <answer id="resources-read">
2.1051 + <p>
2.1052 + XXX no answer for resources-read
2.1053 + </p>
2.1054 + </answer>
2.1055 +
2.1056 +
2.1057 +
2.1058 +<!--
2.1059 + <question id="security-grant" when="final">
2.1060 + Does your code grant additional rights to some other code?
2.1061 + <hint>Avoid using a class loader that adds extra
2.1062 + permissions to loaded code unless really necessary.
2.1063 + Also note that your API implementation
2.1064 + can also expose unneeded permissions to enemy code by
2.1065 + calling AccessController.doPrivileged().</hint>
2.1066 + </question>
2.1067 +-->
2.1068 + <answer id="security-grant">
2.1069 + <p>
2.1070 + XXX no answer for security-grant
2.1071 + </p>
2.1072 + </answer>
2.1073 +
2.1074 +
2.1075 +
2.1076 +<!--
2.1077 + <question id="security-policy" when="final">
2.1078 + Does your functionality require modifications to the standard policy file?
2.1079 + <hint>Your code might pass control to third-party code not
2.1080 + coming from trusted domains. This could be code downloaded over the
2.1081 + network or code coming from libraries that are not bundled
2.1082 + with NetBeans. Which permissions need to be granted to which domains?</hint>
2.1083 + </question>
2.1084 +-->
2.1085 + <answer id="security-policy">
2.1086 + <p>
2.1087 + XXX no answer for security-policy
2.1088 + </p>
2.1089 + </answer>
2.1090 +
2.1091 +</api-answers>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/spring.lookup/build.xml Tue Apr 21 21:41:25 2009 +0200
3.3 @@ -0,0 +1,43 @@
3.4 +<?xml version="1.0" encoding="UTF-8"?>
3.5 +<!--
3.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3.7 +
3.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
3.9 +
3.10 +The contents of this file are subject to the terms of either the GNU
3.11 +General Public License Version 2 only ("GPL") or the Common
3.12 +Development and Distribution License("CDDL") (collectively, the
3.13 +"License"). You may not use this file except in compliance with the
3.14 +License. You can obtain a copy of the License at
3.15 +http://www.netbeans.org/cddl-gplv2.html
3.16 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
3.17 +specific language governing permissions and limitations under the
3.18 +License. When distributing the software, include this License Header
3.19 +Notice in each file and include the License file at
3.20 +nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
3.21 +particular file as subject to the "Classpath" exception as provided
3.22 +by Sun in the GPL Version 2 section of the License file that
3.23 +accompanied this code. If applicable, add the following below the
3.24 +License Header, with the fields enclosed by brackets [] replaced by
3.25 +your own identifying information:
3.26 +"Portions Copyrighted [year] [name of copyright owner]"
3.27 +
3.28 +If you wish your version of this file to be governed by only the CDDL
3.29 +or only the GPL Version 2, indicate your decision by adding
3.30 +"[Contributor] elects to include this software in this distribution
3.31 +under the [CDDL or GPL Version 2] license." If you do not indicate a
3.32 +single choice of license, a recipient has the option to distribute
3.33 +your version of this file under either the CDDL, the GPL Version 2 or
3.34 +to extend the choice of license to its licensees as provided above.
3.35 +However, if you add GPL Version 2 code and therefore, elected the GPL
3.36 +Version 2 license, then the option applies only if the new code is
3.37 +made subject to such option by the copyright holder.
3.38 +
3.39 +Contributor(s):
3.40 +
3.41 +Portions Copyrighted 2008 Sun Microsystems, Inc.
3.42 +-->
3.43 +<project basedir="." default="netbeans" name="contrib/spring.lookup">
3.44 + <description>Builds, tests, and runs the project org.netbeans.modules.spring.lookup</description>
3.45 + <import file="../../nbbuild/templates/projectized.xml"/>
3.46 +</project>
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/spring.lookup/manifest.mf Tue Apr 21 21:41:25 2009 +0200
4.3 @@ -0,0 +1,5 @@
4.4 +Manifest-Version: 1.0
4.5 +OpenIDE-Module: org.netbeans.modules.spring.lookup
4.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/spring/lookup/resources/Bundle.properties
4.7 +OpenIDE-Module-Specification-Version: 1.1
4.8 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/spring.lookup/nbproject/project.properties Tue Apr 21 21:41:25 2009 +0200
5.3 @@ -0,0 +1,42 @@
5.4 +is.autoload=true
5.5 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5.6 +#
5.7 +# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5.8 +#
5.9 +# The contents of this file are subject to the terms of either the GNU
5.10 +# General Public License Version 2 only ("GPL") or the Common
5.11 +# Development and Distribution License("CDDL") (collectively, the
5.12 +# "License"). You may not use this file except in compliance with the
5.13 +# License. You can obtain a copy of the License at
5.14 +# http://www.netbeans.org/cddl-gplv2.html
5.15 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
5.16 +# specific language governing permissions and limitations under the
5.17 +# License. When distributing the software, include this License Header
5.18 +# Notice in each file and include the License file at
5.19 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
5.20 +# particular file as subject to the "Classpath" exception as provided
5.21 +# by Sun in the GPL Version 2 section of the License file that
5.22 +# accompanied this code. If applicable, add the following below the
5.23 +# License Header, with the fields enclosed by brackets [] replaced by
5.24 +# your own identifying information:
5.25 +# "Portions Copyrighted [year] [name of copyright owner]"
5.26 +#
5.27 +# If you wish your version of this file to be governed by only the CDDL
5.28 +# or only the GPL Version 2, indicate your decision by adding
5.29 +# "[Contributor] elects to include this software in this distribution
5.30 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
5.31 +# single choice of license, a recipient has the option to distribute
5.32 +# your version of this file under either the CDDL, the GPL Version 2 or
5.33 +# to extend the choice of license to its licensees as provided above.
5.34 +# However, if you add GPL Version 2 code and therefore, elected the GPL
5.35 +# Version 2 license, then the option applies only if the new code is
5.36 +# made subject to such option by the copyright holder.
5.37 +#
5.38 +# Contributor(s):
5.39 +#
5.40 +# Portions Copyrighted 2008 Sun Microsystems, Inc.
5.41 +javac.source=1.5
5.42 +javac.compilerargs=-Xlint -Xlint:-serial
5.43 +javadoc.apichanges=${basedir}/apichanges.xml
5.44 +
5.45 +javadoc.arch=${basedir}/arch.xml
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/spring.lookup/nbproject/project.xml Tue Apr 21 21:41:25 2009 +0200
6.3 @@ -0,0 +1,68 @@
6.4 +<?xml version="1.0" encoding="UTF-8"?>
6.5 +<!--
6.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
6.7 +
6.8 +Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6.9 +
6.10 +The contents of this file are subject to the terms of either the GNU
6.11 +General Public License Version 2 only ("GPL") or the Common
6.12 +Development and Distribution License("CDDL") (collectively, the
6.13 +"License"). You may not use this file except in compliance with the
6.14 +License. You can obtain a copy of the License at
6.15 +http://www.netbeans.org/cddl-gplv2.html
6.16 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
6.17 +specific language governing permissions and limitations under the
6.18 +License. When distributing the software, include this License Header
6.19 +Notice in each file and include the License file at
6.20 +nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
6.21 +particular file as subject to the "Classpath" exception as provided
6.22 +by Sun in the GPL Version 2 section of the License file that
6.23 +accompanied this code. If applicable, add the following below the
6.24 +License Header, with the fields enclosed by brackets [] replaced by
6.25 +your own identifying information:
6.26 +"Portions Copyrighted [year] [name of copyright owner]"
6.27 +
6.28 +If you wish your version of this file to be governed by only the CDDL
6.29 +or only the GPL Version 2, indicate your decision by adding
6.30 +"[Contributor] elects to include this software in this distribution
6.31 +under the [CDDL or GPL Version 2] license." If you do not indicate a
6.32 +single choice of license, a recipient has the option to distribute
6.33 +your version of this file under either the CDDL, the GPL Version 2 or
6.34 +to extend the choice of license to its licensees as provided above.
6.35 +However, if you add GPL Version 2 code and therefore, elected the GPL
6.36 +Version 2 license, then the option applies only if the new code is
6.37 +made subject to such option by the copyright holder.
6.38 +
6.39 +Contributor(s):
6.40 +
6.41 +Portions Copyrighted 2008 Sun Microsystems, Inc.
6.42 +-->
6.43 +<project xmlns="http://www.netbeans.org/ns/project/1">
6.44 + <type>org.netbeans.modules.apisupport.project</type>
6.45 + <configuration>
6.46 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
6.47 + <code-name-base>org.netbeans.modules.spring.lookup</code-name-base>
6.48 + <module-dependencies>
6.49 + <dependency>
6.50 + <code-name-base>org.netbeans.libs.springframework</code-name-base>
6.51 + <build-prerequisite/>
6.52 + <compile-dependency/>
6.53 + <run-dependency>
6.54 + <specification-version>1.0</specification-version>
6.55 + </run-dependency>
6.56 + </dependency>
6.57 + <dependency>
6.58 + <code-name-base>org.openide.util</code-name-base>
6.59 + <build-prerequisite/>
6.60 + <compile-dependency/>
6.61 + <run-dependency>
6.62 + <specification-version>7.12</specification-version>
6.63 + </run-dependency>
6.64 + </dependency>
6.65 + </module-dependencies>
6.66 + <public-packages>
6.67 + <package>org.netbeans.api.spring</package>
6.68 + </public-packages>
6.69 + </data>
6.70 + </configuration>
6.71 +</project>
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/spring.lookup/src/org/netbeans/api/spring/NbSpring.java Tue Apr 21 21:41:25 2009 +0200
7.3 @@ -0,0 +1,77 @@
7.4 +/*
7.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
7.6 + *
7.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
7.8 + *
7.9 + * The contents of this file are subject to the terms of either the GNU
7.10 + * General Public License Version 2 only ("GPL") or the Common
7.11 + * Development and Distribution License("CDDL") (collectively, the
7.12 + * "License"). You may not use this file except in compliance with the
7.13 + * License. You can obtain a copy of the License at
7.14 + * http://www.netbeans.org/cddl-gplv2.html
7.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
7.16 + * specific language governing permissions and limitations under the
7.17 + * License. When distributing the software, include this License Header
7.18 + * Notice in each file and include the License file at
7.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
7.20 + * particular file as subject to the "Classpath" exception as provided
7.21 + * by Sun in the GPL Version 2 section of the License file that
7.22 + * accompanied this code. If applicable, add the following below the
7.23 + * License Header, with the fields enclosed by brackets [] replaced by
7.24 + * your own identifying information:
7.25 + * "Portions Copyrighted [year] [name of copyright owner]"
7.26 + *
7.27 + * If you wish your version of this file to be governed by only the CDDL
7.28 + * or only the GPL Version 2, indicate your decision by adding
7.29 + * "[Contributor] elects to include this software in this distribution
7.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
7.31 + * single choice of license, a recipient has the option to distribute
7.32 + * your version of this file under either the CDDL, the GPL Version 2 or
7.33 + * to extend the choice of license to its licensees as provided above.
7.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
7.35 + * Version 2 license, then the option applies only if the new code is
7.36 + * made subject to such option by the copyright holder.
7.37 + *
7.38 + * Contributor(s):
7.39 + *
7.40 + * Portions Copyrighted 2008 Sun Microsystems, Inc.
7.41 + */
7.42 +
7.43 +package org.netbeans.api.spring;
7.44 +
7.45 +import org.netbeans.modules.spring.lookup.ApplicationContextBasedLookup;
7.46 +import org.netbeans.modules.spring.lookup.LookupBasedApplicationContext;
7.47 +import org.openide.util.Lookup;
7.48 +import org.springframework.context.ApplicationContext;
7.49 +
7.50 +/** Factory methods to manipulate and bridge NetBeans Lookup and SpringFramework's
7.51 + * ApplicationContext.
7.52 + * @author Jaroslav Tulach, Andrei Badea
7.53 + * @since 1.1
7.54 + */
7.55 +public class NbSpring {
7.56 + private NbSpring() {
7.57 + }
7.58 +
7.59 + /** Converts an application context to lookup.
7.60 + *
7.61 + * @param context application context
7.62 + * @return lookup that bridges to the context
7.63 + */
7.64 + public static Lookup create(ApplicationContext context) {
7.65 + return new ApplicationContextBasedLookup(context);
7.66 + }
7.67 +
7.68 + /** From lookup to application context, if necesary.
7.69 + *
7.70 + * @param context application context
7.71 + * @return lookup that bridges to the context
7.72 + */
7.73 + public static ApplicationContext create(Lookup lookup) {
7.74 + ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
7.75 + if (l == null) {
7.76 + l = NbSpring.class.getClassLoader();
7.77 + }
7.78 + return LookupBasedApplicationContext.create(lookup, l);
7.79 + }
7.80 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/spring.lookup/src/org/netbeans/modules/spring/lookup/ApplicationContextBasedLookup.java Tue Apr 21 21:41:25 2009 +0200
8.3 @@ -0,0 +1,241 @@
8.4 +/*
8.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8.6 + *
8.7 + * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
8.8 + *
8.9 + * The contents of this file are subject to the terms of either the GNU
8.10 + * General Public License Version 2 only ("GPL") or the Common
8.11 + * Development and Distribution License("CDDL") (collectively, the
8.12 + * "License"). You may not use this file except in compliance with the
8.13 + * License. You can obtain a copy of the License at
8.14 + * http://www.netbeans.org/cddl-gplv2.html
8.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
8.16 + * specific language governing permissions and limitations under the
8.17 + * License. When distributing the software, include this License Header
8.18 + * Notice in each file and include the License file at
8.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
8.20 + * particular file as subject to the "Classpath" exception as provided
8.21 + * by Sun in the GPL Version 2 section of the License file that
8.22 + * accompanied this code. If applicable, add the following below the
8.23 + * License Header, with the fields enclosed by brackets [] replaced by
8.24 + * your own identifying information:
8.25 + * "Portions Copyrighted [year] [name of copyright owner]"
8.26 + *
8.27 + * Contributor(s):
8.28 + *
8.29 + * The Original Software is NetBeans. The Initial Developer of the Original
8.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
8.31 + * Microsystems, Inc. All Rights Reserved.
8.32 + *
8.33 + * If you wish your version of this file to be governed by only the CDDL
8.34 + * or only the GPL Version 2, indicate your decision by adding
8.35 + * "[Contributor] elects to include this software in this distribution
8.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
8.37 + * single choice of license, a recipient has the option to distribute
8.38 + * your version of this file under either the CDDL, the GPL Version 2 or
8.39 + * to extend the choice of license to its licensees as provided above.
8.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
8.41 + * Version 2 license, then the option applies only if the new code is
8.42 + * made subject to such option by the copyright holder.
8.43 + */
8.44 +
8.45 +
8.46 +package org.netbeans.modules.spring.lookup;
8.47 +
8.48 +import java.util.ArrayList;
8.49 +import java.util.Collection;
8.50 +import java.util.Collections;
8.51 +import java.util.LinkedHashMap;
8.52 +import java.util.LinkedHashSet;
8.53 +import java.util.List;
8.54 +import java.util.Map;
8.55 +import java.util.Map.Entry;
8.56 +import java.util.Set;
8.57 +import org.openide.util.Lookup;
8.58 +import org.openide.util.LookupListener;
8.59 +import org.springframework.beans.factory.BeanFactoryUtils;
8.60 +import org.springframework.beans.factory.NoSuchBeanDefinitionException;
8.61 +import org.springframework.context.ApplicationContext;
8.62 +
8.63 +/**
8.64 + *
8.65 + * @author Andrei Badea
8.66 + */
8.67 +public class ApplicationContextBasedLookup extends Lookup {
8.68 +
8.69 + // TODO support other bean scopes (prototype, etc.)?
8.70 +
8.71 + private final ApplicationContext appContext;
8.72 +
8.73 + public ApplicationContextBasedLookup(ApplicationContext appContext) {
8.74 + this.appContext = appContext;
8.75 + }
8.76 +
8.77 + @Override
8.78 + public <T> T lookup(Class<T> clazz) {
8.79 + return lookupBean(clazz);
8.80 + }
8.81 +
8.82 + @Override
8.83 + public <T> Result<T> lookup(Template<T> template) {
8.84 + return new ResultImpl<T>(template);
8.85 + }
8.86 +
8.87 + private <T> T lookupBean(Class<T> type) {
8.88 + @SuppressWarnings("unchecked")
8.89 + Map<String, ? extends T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(appContext, type, false, true);
8.90 + for (T instance : beans.values()) {
8.91 + return instance;
8.92 + }
8.93 + return null;
8.94 + }
8.95 +
8.96 + private <T> T lookupBean(String id, Class<T> type) {
8.97 + try {
8.98 + @SuppressWarnings("unchecked")
8.99 + T bean = (T)appContext.getBean(id, type);
8.100 + return bean;
8.101 + } catch (NoSuchBeanDefinitionException e) {
8.102 + return null;
8.103 + }
8.104 + }
8.105 +
8.106 + private <T> Map<String, ? extends T> lookupBeans(Template<T> template) {
8.107 + String id = template.getId();
8.108 + Class<T> type = template.getType();
8.109 + T instance = template.getInstance();
8.110 + if (id != null) {
8.111 + T bean = lookupBean(id, type);
8.112 + if (instance != null && instance != bean) {
8.113 + bean = null;
8.114 + }
8.115 + return bean != null ? Collections.singletonMap(id, bean) : Collections.<String, T>emptyMap();
8.116 + } else {
8.117 + @SuppressWarnings("unchecked")
8.118 + Map<String, ? extends T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(appContext, type, false, true);
8.119 + if (instance != null) {
8.120 + Map<String, T> instanceMatch = new LinkedHashMap<String, T>();
8.121 + for (Entry<String, ? extends T> entry : beans.entrySet()) {
8.122 + if (entry.getValue() == instance) {
8.123 + instanceMatch.put(entry.getKey(), instance);
8.124 + }
8.125 + }
8.126 + beans = instanceMatch;
8.127 + }
8.128 + Map<String, T> computed = new LinkedHashMap<String, T>(beans);
8.129 + for (Entry<String, ? extends T> entry : beans.entrySet()) {
8.130 + for (String alias : appContext.getAliases(entry.getKey())) {
8.131 + computed.put(alias, entry.getValue());
8.132 + }
8.133 + }
8.134 + return computed;
8.135 + }
8.136 + }
8.137 +
8.138 + private final class ResultImpl<T> extends Result<T> {
8.139 +
8.140 + private final Template<T> template;
8.141 +
8.142 + // @GuardedBy("this")
8.143 + private Map<String, ? extends T> beans;
8.144 + // @GuardedBy("this")
8.145 + private List<Item<T>> items;
8.146 + // @GuardedBy("this")
8.147 + private Set<Class<? extends T>> classes;
8.148 + // @GuardedBy("this")
8.149 + private List<? extends T> instances;
8.150 +
8.151 + public ResultImpl(Template<T> template) {
8.152 + this.template = template;
8.153 + }
8.154 +
8.155 + @Override
8.156 + public synchronized Collection<? extends T> allInstances() {
8.157 + if (instances != null) {
8.158 + return instances;
8.159 + }
8.160 + List<T> newInstances = new ArrayList<T>();
8.161 + for (Entry<String, ? extends T> entry : allBeans().entrySet()) {
8.162 + newInstances.add(entry.getValue());
8.163 + }
8.164 + instances = Collections.unmodifiableList(newInstances);
8.165 + return instances;
8.166 + }
8.167 +
8.168 + @Override
8.169 + public synchronized Set<Class<? extends T>> allClasses() {
8.170 + if (classes != null) {
8.171 + return classes;
8.172 + }
8.173 + Set<Class<? extends T>> newClasses = new LinkedHashSet<Class<? extends T>>();
8.174 + for (Entry<String, ? extends T> entry : allBeans().entrySet()) {
8.175 + @SuppressWarnings("unchecked")
8.176 + Class<? extends T> clazz = (Class<? extends T>)entry.getValue().getClass();
8.177 + newClasses.add(clazz);
8.178 + }
8.179 + classes = Collections.<Class<? extends T>>unmodifiableSet(newClasses);
8.180 + return classes;
8.181 + }
8.182 +
8.183 + @Override
8.184 + public synchronized Collection<Item<T>> allItems() {
8.185 + if (items != null) {
8.186 + return items;
8.187 + }
8.188 + List<Item<T>> newItems = new ArrayList<Item<T>>();
8.189 + for (Entry<String, ? extends T> entry : allBeans().entrySet()) {
8.190 + newItems.add(new ItemImpl<T>(entry.getKey(), entry.getValue()));
8.191 + }
8.192 + items = Collections.unmodifiableList(newItems);
8.193 + return newItems;
8.194 + }
8.195 +
8.196 + private synchronized Map<String, ? extends T> allBeans() {
8.197 + if (beans == null) {
8.198 + beans = lookupBeans(template);
8.199 + }
8.200 + return beans;
8.201 + }
8.202 +
8.203 + @Override
8.204 + public void addLookupListener(LookupListener l) {
8.205 + }
8.206 +
8.207 + @Override
8.208 + public void removeLookupListener(LookupListener l) {
8.209 + }
8.210 + }
8.211 +
8.212 + private static final class ItemImpl<T> extends Item<T> {
8.213 +
8.214 + private final T instance;
8.215 + private final String id;
8.216 +
8.217 + public ItemImpl(String id, T instance) {
8.218 + this.id = id != null ? id : "";
8.219 + assert instance != null;
8.220 + this.instance = instance;
8.221 + }
8.222 +
8.223 + @Override
8.224 + public T getInstance() {
8.225 + return instance;
8.226 + }
8.227 +
8.228 + @Override
8.229 + @SuppressWarnings("unchecked")
8.230 + public Class<? extends T> getType() {
8.231 + return (Class<? extends T>)instance.getClass();
8.232 + }
8.233 +
8.234 + @Override
8.235 + public String getId() {
8.236 + return id;
8.237 + }
8.238 +
8.239 + @Override
8.240 + public String getDisplayName() {
8.241 + return getId();
8.242 + }
8.243 + }
8.244 +}
8.245 \ No newline at end of file
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/spring.lookup/src/org/netbeans/modules/spring/lookup/LookupBasedApplicationContext.java Tue Apr 21 21:41:25 2009 +0200
9.3 @@ -0,0 +1,254 @@
9.4 +/*
9.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
9.6 + *
9.7 + * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
9.8 + *
9.9 + * The contents of this file are subject to the terms of either the GNU
9.10 + * General Public License Version 2 only ("GPL") or the Common
9.11 + * Development and Distribution License("CDDL") (collectively, the
9.12 + * "License"). You may not use this file except in compliance with the
9.13 + * License. You can obtain a copy of the License at
9.14 + * http://www.netbeans.org/cddl-gplv2.html
9.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
9.16 + * specific language governing permissions and limitations under the
9.17 + * License. When distributing the software, include this License Header
9.18 + * Notice in each file and include the License file at
9.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
9.20 + * particular file as subject to the "Classpath" exception as provided
9.21 + * by Sun in the GPL Version 2 section of the License file that
9.22 + * accompanied this code. If applicable, add the following below the
9.23 + * License Header, with the fields enclosed by brackets [] replaced by
9.24 + * your own identifying information:
9.25 + * "Portions Copyrighted [year] [name of copyright owner]"
9.26 + *
9.27 + * Contributor(s):
9.28 + *
9.29 + * The Original Software is NetBeans. The Initial Developer of the Original
9.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
9.31 + * Microsystems, Inc. All Rights Reserved.
9.32 + *
9.33 + * If you wish your version of this file to be governed by only the CDDL
9.34 + * or only the GPL Version 2, indicate your decision by adding
9.35 + * "[Contributor] elects to include this software in this distribution
9.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
9.37 + * single choice of license, a recipient has the option to distribute
9.38 + * your version of this file under either the CDDL, the GPL Version 2 or
9.39 + * to extend the choice of license to its licensees as provided above.
9.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
9.41 + * Version 2 license, then the option applies only if the new code is
9.42 + * made subject to such option by the copyright holder.
9.43 + */
9.44 +
9.45 +package org.netbeans.modules.spring.lookup;
9.46 +
9.47 +import java.io.IOException;
9.48 +import java.util.ArrayList;
9.49 +import java.util.HashMap;
9.50 +import java.util.List;
9.51 +import java.util.Locale;
9.52 +import java.util.Map;
9.53 +import org.openide.util.Lookup;
9.54 +import org.openide.util.Lookup.Item;
9.55 +import org.openide.util.Lookup.Template;
9.56 +import org.springframework.beans.BeansException;
9.57 +import org.springframework.beans.factory.BeanDefinitionStoreException;
9.58 +import org.springframework.beans.factory.BeanFactory;
9.59 +import org.springframework.beans.factory.NoSuchBeanDefinitionException;
9.60 +import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
9.61 +import org.springframework.context.ApplicationContext;
9.62 +import org.springframework.context.ApplicationEvent;
9.63 +import org.springframework.context.MessageSourceResolvable;
9.64 +import org.springframework.context.NoSuchMessageException;
9.65 +import org.springframework.core.io.DefaultResourceLoader;
9.66 +import org.springframework.core.io.Resource;
9.67 +import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
9.68 +import org.springframework.core.io.support.ResourcePatternResolver;
9.69 +
9.70 +/**
9.71 + *
9.72 + * @author Andrei Badea
9.73 + */
9.74 +@SuppressWarnings("unchecked")
9.75 +public class LookupBasedApplicationContext extends DefaultResourceLoader implements ApplicationContext {
9.76 +
9.77 + private final Lookup lookup;
9.78 + private final ResourcePatternResolver resourcePatternResolver;
9.79 + private final long startupDate = System.currentTimeMillis();
9.80 +
9.81 + public static ApplicationContext create(Lookup lookup) {
9.82 + ClassLoader loader = lookup.lookup(ClassLoader.class);
9.83 + if (loader == null) {
9.84 + throw new IllegalArgumentException();
9.85 + }
9.86 + return create(lookup, loader);
9.87 + }
9.88 +
9.89 + public static ApplicationContext create(Lookup lookup, ClassLoader loader) {
9.90 + return new LookupBasedApplicationContext(lookup, loader);
9.91 + }
9.92 +
9.93 + private LookupBasedApplicationContext(Lookup lookup, ClassLoader loader) {
9.94 + super(loader);
9.95 + this.lookup = lookup;
9.96 + this.resourcePatternResolver = new PathMatchingResourcePatternResolver(this);
9.97 + }
9.98 +
9.99 + // ListableBeanFactory methods.
9.100 +
9.101 + public Object getBean(String name) throws BeansException {
9.102 + return getBean(name, (Class)null);
9.103 + }
9.104 +
9.105 + public Object getBean(String name, Class requiredType) throws BeansException {
9.106 + Item item = lookup.lookupItem(new Template(requiredType, name, null));
9.107 + return item != null ? item.getInstance() : null;
9.108 + }
9.109 +
9.110 + public Object getBean(String name, Object[] args) throws BeansException {
9.111 + Object instance = getBean(name);
9.112 + // Javadoc seems to imply that if arguments are given, a prototype bean
9.113 + // is expected.
9.114 + if (args.length == 0 && instance != null) {
9.115 + return instance;
9.116 + }
9.117 + if (instance != null) {
9.118 + throw new BeanDefinitionStoreException("No such bean " + name);
9.119 + }
9.120 + throw new NoSuchBeanDefinitionException(name);
9.121 + }
9.122 +
9.123 + public boolean containsBean(String name) {
9.124 + return getBean(name) != null;
9.125 + }
9.126 +
9.127 + public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
9.128 + if (containsBean(name)) {
9.129 + return true;
9.130 + }
9.131 + throw new NoSuchBeanDefinitionException(name);
9.132 + }
9.133 +
9.134 + public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
9.135 + if (containsBean(name)) {
9.136 + return false;
9.137 + }
9.138 + throw new NoSuchBeanDefinitionException(name);
9.139 + }
9.140 +
9.141 + public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
9.142 + Object bean = getBean(name);
9.143 + if (bean != null) {
9.144 + return targetType.isInstance(bean);
9.145 + }
9.146 + throw new NoSuchBeanDefinitionException(name);
9.147 + }
9.148 +
9.149 + public Class getType(String name) throws NoSuchBeanDefinitionException {
9.150 + Object bean = getBean(name);
9.151 + if (bean != null) {
9.152 + return bean.getClass();
9.153 + }
9.154 + throw new NoSuchBeanDefinitionException(name);
9.155 + }
9.156 +
9.157 + public String[] getAliases(String name) {
9.158 + return new String[0];
9.159 + }
9.160 +
9.161 + public boolean containsBeanDefinition(String beanName) {
9.162 + return containsBean(beanName);
9.163 + }
9.164 +
9.165 + public int getBeanDefinitionCount() {
9.166 + return lookup.lookupAll(Object.class).size();
9.167 + }
9.168 +
9.169 + public String[] getBeanDefinitionNames() {
9.170 + return getBeanNamesForType(Object.class);
9.171 + }
9.172 +
9.173 + public String[] getBeanNamesForType(Class type) {
9.174 + return getBeanNamesForType(type, false, false);
9.175 + }
9.176 +
9.177 + public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean allowEagerInit) {
9.178 + List<String> names = new ArrayList<String>();
9.179 + for (Item item : lookup.lookupResult((Class<?>)type).allItems()) {
9.180 + String name = item.getId();
9.181 + if (name != null) {
9.182 + names.add(name);
9.183 + }
9.184 + }
9.185 + return names.toArray(new String[names.size()]);
9.186 + }
9.187 +
9.188 + public Map getBeansOfType(Class type) throws BeansException {
9.189 + return getBeansOfType(type, false, false);
9.190 + }
9.191 +
9.192 + public Map getBeansOfType(Class type, boolean includePrototypes, boolean allowEagerInit) throws BeansException {
9.193 + Map map = new HashMap();
9.194 + for (Item item : lookup.lookupResult((Class<?>)type).allItems()) {
9.195 + String name = item.getId();
9.196 + if (name != null) {
9.197 + map.put(name, item.getInstance());
9.198 + }
9.199 + }
9.200 + return map;
9.201 + }
9.202 +
9.203 + // ApplicationContext methods.
9.204 +
9.205 + public ApplicationContext getParent() {
9.206 + return null;
9.207 + }
9.208 +
9.209 + public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
9.210 + throw new IllegalStateException("No autowire capable bean factory");
9.211 + }
9.212 +
9.213 + public String getDisplayName() {
9.214 + return null;
9.215 + }
9.216 +
9.217 + public long getStartupDate() {
9.218 + return startupDate;
9.219 + }
9.220 +
9.221 + // HierarchicalBeanFactory methods.
9.222 +
9.223 + public BeanFactory getParentBeanFactory() {
9.224 + return null;
9.225 + }
9.226 +
9.227 + public boolean containsLocalBean(String name) {
9.228 + return containsBean(name);
9.229 + }
9.230 +
9.231 + // MessageSource methods.
9.232 +
9.233 + public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
9.234 + throw new UnsupportedOperationException("Not supported yet.");
9.235 + }
9.236 +
9.237 + public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
9.238 + throw new UnsupportedOperationException("Not supported yet.");
9.239 + }
9.240 +
9.241 + public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
9.242 + throw new UnsupportedOperationException("Not supported yet.");
9.243 + }
9.244 +
9.245 + // ApplicationEventPublisher methods.
9.246 +
9.247 + public void publishEvent(ApplicationEvent event) {
9.248 + }
9.249 +
9.250 + // ResourcePatternResolver methods.
9.251 +
9.252 + public Resource[] getResources(String locationPattern) throws IOException {
9.253 + return resourcePatternResolver.getResources(locationPattern);
9.254 + }
9.255 +
9.256 + // ResourceLoader methods implemented in superclass.
9.257 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/spring.lookup/src/org/netbeans/modules/spring/lookup/resources/Bundle.properties Tue Apr 21 21:41:25 2009 +0200
10.3 @@ -0,0 +1,37 @@
10.4 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
10.5 +#
10.6 +# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
10.7 +#
10.8 +# The contents of this file are subject to the terms of either the GNU
10.9 +# General Public License Version 2 only ("GPL") or the Common
10.10 +# Development and Distribution License("CDDL") (collectively, the
10.11 +# "License"). You may not use this file except in compliance with the
10.12 +# License. You can obtain a copy of the License at
10.13 +# http://www.netbeans.org/cddl-gplv2.html
10.14 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
10.15 +# specific language governing permissions and limitations under the
10.16 +# License. When distributing the software, include this License Header
10.17 +# Notice in each file and include the License file at
10.18 +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
10.19 +# particular file as subject to the "Classpath" exception as provided
10.20 +# by Sun in the GPL Version 2 section of the License file that
10.21 +# accompanied this code. If applicable, add the following below the
10.22 +# License Header, with the fields enclosed by brackets [] replaced by
10.23 +# your own identifying information:
10.24 +# "Portions Copyrighted [year] [name of copyright owner]"
10.25 +#
10.26 +# If you wish your version of this file to be governed by only the CDDL
10.27 +# or only the GPL Version 2, indicate your decision by adding
10.28 +# "[Contributor] elects to include this software in this distribution
10.29 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
10.30 +# single choice of license, a recipient has the option to distribute
10.31 +# your version of this file under either the CDDL, the GPL Version 2 or
10.32 +# to extend the choice of license to its licensees as provided above.
10.33 +# However, if you add GPL Version 2 code and therefore, elected the GPL
10.34 +# Version 2 license, then the option applies only if the new code is
10.35 +# made subject to such option by the copyright holder.
10.36 +#
10.37 +# Contributor(s):
10.38 +#
10.39 +# Portions Copyrighted 2008 Sun Microsystems, Inc.
10.40 +OpenIDE-Module-Name=spring.lookup
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/spring.lookup/test/unit/src/org/netbeans/modules/spring/lookup/ApplicationContextBasedLookupTest.java Tue Apr 21 21:41:25 2009 +0200
11.3 @@ -0,0 +1,155 @@
11.4 +/*
11.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
11.6 + *
11.7 + * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
11.8 + *
11.9 + * The contents of this file are subject to the terms of either the GNU
11.10 + * General Public License Version 2 only ("GPL") or the Common
11.11 + * Development and Distribution License("CDDL") (collectively, the
11.12 + * "License"). You may not use this file except in compliance with the
11.13 + * License. You can obtain a copy of the License at
11.14 + * http://www.netbeans.org/cddl-gplv2.html
11.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
11.16 + * specific language governing permissions and limitations under the
11.17 + * License. When distributing the software, include this License Header
11.18 + * Notice in each file and include the License file at
11.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
11.20 + * particular file as subject to the "Classpath" exception as provided
11.21 + * by Sun in the GPL Version 2 section of the License file that
11.22 + * accompanied this code. If applicable, add the following below the
11.23 + * License Header, with the fields enclosed by brackets [] replaced by
11.24 + * your own identifying information:
11.25 + * "Portions Copyrighted [year] [name of copyright owner]"
11.26 + *
11.27 + * Contributor(s):
11.28 + *
11.29 + * The Original Software is NetBeans. The Initial Developer of the Original
11.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
11.31 + * Microsystems, Inc. All Rights Reserved.
11.32 + *
11.33 + * If you wish your version of this file to be governed by only the CDDL
11.34 + * or only the GPL Version 2, indicate your decision by adding
11.35 + * "[Contributor] elects to include this software in this distribution
11.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
11.37 + * single choice of license, a recipient has the option to distribute
11.38 + * your version of this file under either the CDDL, the GPL Version 2 or
11.39 + * to extend the choice of license to its licensees as provided above.
11.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
11.41 + * Version 2 license, then the option applies only if the new code is
11.42 + * made subject to such option by the copyright holder.
11.43 + */
11.44 +
11.45 +package org.netbeans.modules.spring.lookup;
11.46 +
11.47 +import java.util.ArrayList;
11.48 +import java.util.HashMap;
11.49 +import java.util.HashSet;
11.50 +import java.util.Iterator;
11.51 +import java.util.LinkedList;
11.52 +import java.util.List;
11.53 +import java.util.Map;
11.54 +import java.util.Set;
11.55 +import junit.framework.TestCase;
11.56 +import org.openide.util.Lookup;
11.57 +import org.openide.util.Lookup.Item;
11.58 +import org.openide.util.Lookup.Result;
11.59 +import org.openide.util.Lookup.Template;
11.60 +import org.springframework.context.ApplicationContext;
11.61 +
11.62 +/**
11.63 + *
11.64 + * @author Andrei Badea
11.65 + */
11.66 +public class ApplicationContextBasedLookupTest extends TestCase {
11.67 +
11.68 + public ApplicationContextBasedLookupTest(String testName) {
11.69 + super(testName);
11.70 + }
11.71 +
11.72 + public void testLookupSingle() throws Exception {
11.73 + ApplicationContext ctx = TestUtils.createAppContext(
11.74 + "<bean id='foo' class='java.util.ArrayList'/>" +
11.75 + "<bean id='baz' class='java.util.HashMap'/>");
11.76 + ArrayList foo = (ArrayList)ctx.getBean("foo");
11.77 + HashMap baz = (HashMap)ctx.getBean("baz");
11.78 + Lookup lookup = new ApplicationContextBasedLookup(ctx);
11.79 +
11.80 + assertSame(foo, lookup.lookup(List.class));
11.81 + assertSame(foo, lookup.lookup(ArrayList.class));
11.82 + assertSame(baz, lookup.lookup(Map.class));
11.83 + // Order should be preserved.
11.84 + assertSame(foo, lookup.lookup(Object.class));
11.85 + }
11.86 +
11.87 + public void testItem() throws Exception {
11.88 + ApplicationContext ctx = TestUtils.createAppContext(
11.89 + "<bean id='foo' class='java.util.ArrayList'/>");
11.90 + ArrayList foo = (ArrayList)ctx.getBean("foo");
11.91 + Lookup lookup = new ApplicationContextBasedLookup(ctx);
11.92 +
11.93 + Item item = lookup.lookupItem(new Template<List>(List.class, null, null));
11.94 + assertEquals("foo", item.getId());
11.95 + assertEquals("foo", item.getDisplayName());
11.96 + assertSame(ArrayList.class, item.getType());
11.97 + assertSame(foo, item.getInstance());
11.98 + }
11.99 +
11.100 + public void testLookupResult() throws Exception {
11.101 + ApplicationContext ctx = TestUtils.createAppContext(
11.102 + "<bean id='foo' class='java.util.ArrayList'/>" +
11.103 + "<bean id='bar' class='java.util.LinkedList'/>" +
11.104 + "<bean id='baz' class='java.util.HashMap'/>");
11.105 + ArrayList foo = (ArrayList)ctx.getBean("foo");
11.106 + LinkedList bar = (LinkedList)ctx.getBean("bar");
11.107 + HashMap baz = (HashMap)ctx.getBean("baz");
11.108 + Lookup lookup = new ApplicationContextBasedLookup(ctx);
11.109 +
11.110 + assertSame(foo, lookup.lookupItem(new Template<List>(List.class, null, foo)).getInstance());
11.111 + assertSame(bar, lookup.lookupItem(new Template<List>(List.class, "bar", bar)).getInstance());
11.112 +
11.113 + assertNull(lookup.lookupItem(new Template<List>(List.class, "none", null)));
11.114 + assertNull(lookup.lookupItem(new Template<List>(List.class, "foo", bar)));
11.115 +
11.116 + Result<List> listResult = lookup.lookupResult(List.class);
11.117 + Iterator<Class<? extends List>> listClassIterator = listResult.allClasses().iterator();
11.118 + assertSame(ArrayList.class, listClassIterator.next());
11.119 + assertSame(LinkedList.class, listClassIterator.next());
11.120 + assertFalse(listClassIterator.hasNext());
11.121 + Iterator<? extends List> listIterator = listResult.allInstances().iterator();
11.122 + assertSame(foo, listIterator.next());
11.123 + assertSame(bar, listIterator.next());
11.124 + assertFalse(listIterator.hasNext());
11.125 + }
11.126 +
11.127 + public void testAliases() throws Exception {
11.128 + ApplicationContext ctx = TestUtils.createAppContext(
11.129 + "<alias name='foo' alias='bar'/>" +
11.130 + "<bean id='foo' class='java.util.ArrayList'/>" +
11.131 + "<bean id='baz' class='java.util.HashMap'/>");
11.132 + ArrayList foo = (ArrayList)ctx.getBean("foo");
11.133 + Lookup lookup = new ApplicationContextBasedLookup(ctx);
11.134 +
11.135 + assertSame(foo, lookup.lookupItem(new Template<List>(List.class, "bar", null)).getInstance());
11.136 +
11.137 + Result<List> result = lookup.lookup(new Template<List>(List.class, null, foo));
11.138 + Iterator<? extends Item<List>> iterator = result.allItems().iterator();
11.139 + Set<String> ids = new HashSet<String>();
11.140 + Item item = iterator.next();
11.141 + assertSame(foo, item.getInstance());
11.142 + ids.add(item.getId());
11.143 + item = iterator.next();
11.144 + assertSame(foo, item.getInstance());
11.145 + ids.add(item.getId());
11.146 + assertEquals(2, ids.size());
11.147 + assertTrue(ids.contains("foo"));
11.148 + assertTrue(ids.contains("bar"));
11.149 + }
11.150 +
11.151 + public void testPrototypesIgnored() throws Exception {
11.152 + ApplicationContext ctx = TestUtils.createAppContext(
11.153 + "<bean id='foo' class='java.util.ArrayList' scope='prototype'/>");
11.154 + Lookup lookup = new ApplicationContextBasedLookup(ctx);
11.155 +
11.156 + assertNull(lookup.lookup(List.class));
11.157 + }
11.158 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/spring.lookup/test/unit/src/org/netbeans/modules/spring/lookup/LookupBasedApplicationContextTest.java Tue Apr 21 21:41:25 2009 +0200
12.3 @@ -0,0 +1,184 @@
12.4 +/*
12.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
12.6 + *
12.7 + * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
12.8 + *
12.9 + * The contents of this file are subject to the terms of either the GNU
12.10 + * General Public License Version 2 only ("GPL") or the Common
12.11 + * Development and Distribution License("CDDL") (collectively, the
12.12 + * "License"). You may not use this file except in compliance with the
12.13 + * License. You can obtain a copy of the License at
12.14 + * http://www.netbeans.org/cddl-gplv2.html
12.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
12.16 + * specific language governing permissions and limitations under the
12.17 + * License. When distributing the software, include this License Header
12.18 + * Notice in each file and include the License file at
12.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
12.20 + * particular file as subject to the "Classpath" exception as provided
12.21 + * by Sun in the GPL Version 2 section of the License file that
12.22 + * accompanied this code. If applicable, add the following below the
12.23 + * License Header, with the fields enclosed by brackets [] replaced by
12.24 + * your own identifying information:
12.25 + * "Portions Copyrighted [year] [name of copyright owner]"
12.26 + *
12.27 + * Contributor(s):
12.28 + *
12.29 + * The Original Software is NetBeans. The Initial Developer of the Original
12.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
12.31 + * Microsystems, Inc. All Rights Reserved.
12.32 + *
12.33 + * If you wish your version of this file to be governed by only the CDDL
12.34 + * or only the GPL Version 2, indicate your decision by adding
12.35 + * "[Contributor] elects to include this software in this distribution
12.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
12.37 + * single choice of license, a recipient has the option to distribute
12.38 + * your version of this file under either the CDDL, the GPL Version 2 or
12.39 + * to extend the choice of license to its licensees as provided above.
12.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
12.41 + * Version 2 license, then the option applies only if the new code is
12.42 + * made subject to such option by the copyright holder.
12.43 + */
12.44 +
12.45 +package org.netbeans.modules.spring.lookup;
12.46 +
12.47 +import java.util.ArrayList;
12.48 +import java.util.HashMap;
12.49 +import java.util.LinkedList;
12.50 +import java.util.List;
12.51 +import java.util.Map;
12.52 +import junit.framework.TestCase;
12.53 +import org.openide.util.Lookup;
12.54 +import org.openide.util.lookup.AbstractLookup;
12.55 +import org.openide.util.lookup.AbstractLookup.Content;
12.56 +import org.openide.util.lookup.AbstractLookup.Pair;
12.57 +import org.springframework.beans.factory.BeanDefinitionStoreException;
12.58 +import org.springframework.beans.factory.NoSuchBeanDefinitionException;
12.59 +import org.springframework.context.ApplicationContext;
12.60 +
12.61 +/**
12.62 + *
12.63 + * @author Andrei Badea
12.64 + */
12.65 +public class LookupBasedApplicationContextTest extends TestCase {
12.66 +
12.67 + // TODO test others ApplicationContext methods.
12.68 +
12.69 + public LookupBasedApplicationContextTest(String testName) {
12.70 + super(testName);
12.71 + }
12.72 +
12.73 + public void testBeanFactoryMethods() {
12.74 + Content content = new Content();
12.75 + ArrayList array = new ArrayList();
12.76 + LinkedList linked = new LinkedList();
12.77 + content.addPair(new PairImpl<Object>("array", array));
12.78 + content.addPair(new PairImpl<Object>("linked", linked));
12.79 + content.addPair(new PairImpl<Object>(null, new HashMap()));
12.80 + Lookup lookup = new AbstractLookup(content);
12.81 + ApplicationContext ctx = LookupBasedApplicationContext.create(lookup, this.getClass().getClassLoader());
12.82 +
12.83 + assertSame(array, ctx.getBean("array"));
12.84 +
12.85 + assertSame(array, ctx.getBean("array", ArrayList.class));
12.86 + // Order should be preserved.
12.87 + assertSame(array, ctx.getBean("array", List.class));
12.88 + assertNull(ctx.getBean("array", LinkedList.class));
12.89 +
12.90 + assertSame(array, ctx.getBean("array", new Object[0]));
12.91 + try {
12.92 + ctx.getBean("array", new Object[] { null });
12.93 + fail();
12.94 + } catch (BeanDefinitionStoreException e) {}
12.95 + try {
12.96 + ctx.getBean("foo", new Object[0]);
12.97 + fail();
12.98 + } catch (NoSuchBeanDefinitionException e) {}
12.99 +
12.100 + assertTrue(ctx.containsBean("array"));
12.101 + assertFalse(ctx.containsBean("foo"));
12.102 +
12.103 + assertTrue(ctx.isSingleton("array"));
12.104 + try {
12.105 + ctx.isSingleton("foo");
12.106 + } catch (NoSuchBeanDefinitionException e) {}
12.107 +
12.108 + assertFalse(ctx.isPrototype("array"));
12.109 + try {
12.110 + ctx.isPrototype("foo");
12.111 + } catch (NoSuchBeanDefinitionException e) {}
12.112 +
12.113 + assertTrue(ctx.isTypeMatch("array", ArrayList.class));
12.114 + assertTrue(ctx.isTypeMatch("array", List.class));
12.115 + assertFalse(ctx.isTypeMatch("linked", ArrayList.class));
12.116 + try {
12.117 + ctx.isTypeMatch("foo", Object.class);
12.118 + } catch (NoSuchBeanDefinitionException e) {}
12.119 +
12.120 + assertSame(ArrayList.class, ctx.getType("array"));
12.121 +
12.122 + assertTrue(ctx.containsBeanDefinition("array"));
12.123 + assertFalse(ctx.containsBeanDefinition("foo"));
12.124 +
12.125 + assertEquals(3, ctx.getBeanDefinitionCount());
12.126 +
12.127 + String[] names = ctx.getBeanDefinitionNames();
12.128 + assertEquals(2, names.length);
12.129 + assertEquals("array", names[0]);
12.130 + assertEquals("linked", names[1]);
12.131 +
12.132 + names = ctx.getBeanNamesForType(List.class);
12.133 + assertEquals(2, names.length);
12.134 + assertEquals("array", names[0]);
12.135 + assertEquals("linked", names[1]);
12.136 +
12.137 + Map beans = ctx.getBeansOfType(List.class);
12.138 + assertEquals(2, beans.size());
12.139 + assertSame(array, beans.get("array"));
12.140 + assertSame(linked, beans.get("linked"));
12.141 +
12.142 + assertTrue(ctx.containsLocalBean("array"));
12.143 + assertFalse(ctx.containsLocalBean("foo"));
12.144 + }
12.145 +
12.146 + private static final class PairImpl<T> extends Pair<T> {
12.147 +
12.148 + private final String id;
12.149 + private final T instance;
12.150 +
12.151 + public PairImpl(String id, T instance) {
12.152 + this.id = id;
12.153 + this.instance = instance;
12.154 + }
12.155 +
12.156 + @Override
12.157 + protected boolean instanceOf(Class<?> c) {
12.158 + return c.isInstance(instance);
12.159 + }
12.160 +
12.161 + @Override
12.162 + protected boolean creatorOf(Object obj) {
12.163 + return obj == instance;
12.164 + }
12.165 +
12.166 + @Override
12.167 + public T getInstance() {
12.168 + return instance;
12.169 + }
12.170 +
12.171 + @Override
12.172 + @SuppressWarnings("unchecked")
12.173 + public Class<? extends T> getType() {
12.174 + return (Class<? extends T>)instance.getClass();
12.175 + }
12.176 +
12.177 + @Override
12.178 + public String getId() {
12.179 + return id;
12.180 + }
12.181 +
12.182 + @Override
12.183 + public String getDisplayName() {
12.184 + return getId();
12.185 + }
12.186 + }
12.187 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/spring.lookup/test/unit/src/org/netbeans/modules/spring/lookup/TestUtils.java Tue Apr 21 21:41:25 2009 +0200
13.3 @@ -0,0 +1,77 @@
13.4 +/*
13.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
13.6 + *
13.7 + * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
13.8 + *
13.9 + * The contents of this file are subject to the terms of either the GNU
13.10 + * General Public License Version 2 only ("GPL") or the Common
13.11 + * Development and Distribution License("CDDL") (collectively, the
13.12 + * "License"). You may not use this file except in compliance with the
13.13 + * License. You can obtain a copy of the License at
13.14 + * http://www.netbeans.org/cddl-gplv2.html
13.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13.16 + * specific language governing permissions and limitations under the
13.17 + * License. When distributing the software, include this License Header
13.18 + * Notice in each file and include the License file at
13.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
13.20 + * particular file as subject to the "Classpath" exception as provided
13.21 + * by Sun in the GPL Version 2 section of the License file that
13.22 + * accompanied this code. If applicable, add the following below the
13.23 + * License Header, with the fields enclosed by brackets [] replaced by
13.24 + * your own identifying information:
13.25 + * "Portions Copyrighted [year] [name of copyright owner]"
13.26 + *
13.27 + * Contributor(s):
13.28 + *
13.29 + * The Original Software is NetBeans. The Initial Developer of the Original
13.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
13.31 + * Microsystems, Inc. All Rights Reserved.
13.32 + *
13.33 + * If you wish your version of this file to be governed by only the CDDL
13.34 + * or only the GPL Version 2, indicate your decision by adding
13.35 + * "[Contributor] elects to include this software in this distribution
13.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
13.37 + * single choice of license, a recipient has the option to distribute
13.38 + * your version of this file under either the CDDL, the GPL Version 2 or
13.39 + * to extend the choice of license to its licensees as provided above.
13.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
13.41 + * Version 2 license, then the option applies only if the new code is
13.42 + * made subject to such option by the copyright holder.
13.43 + */
13.44 +
13.45 +package org.netbeans.modules.spring.lookup;
13.46 +
13.47 +import java.io.ByteArrayInputStream;
13.48 +import java.io.IOException;
13.49 +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
13.50 +import org.springframework.context.ApplicationContext;
13.51 +import org.springframework.context.support.GenericApplicationContext;
13.52 +import org.xml.sax.InputSource;
13.53 +
13.54 +/**
13.55 + *
13.56 + * @author Andrei Badea
13.57 + */
13.58 +public class TestUtils {
13.59 +
13.60 + public static InputSource createInputSource(String contents) throws IOException {
13.61 + String xml =
13.62 + "<?xml version='1.0' encoding='UTF-8'?>" +
13.63 + "<beans xmlns='http://www.springframework.org/schema/beans'" +
13.64 + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
13.65 + " xsi:schemaLocation='http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd'>" +
13.66 + contents +
13.67 + "</beans>";
13.68 + return new InputSource(new ByteArrayInputStream(xml.getBytes("UTF-8")));
13.69 + }
13.70 +
13.71 + public static ApplicationContext createAppContext(String contents) throws IOException {
13.72 + GenericApplicationContext appContext = new GenericApplicationContext();
13.73 + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
13.74 + reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
13.75 + reader.loadBeanDefinitions(createInputSource(contents));
13.76 + appContext.refresh();
13.77 + return appContext;
13.78 + }
13.79 +}
13.80 +