Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8003759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:44:23+00:00 2026-06-04T16:44:23+00:00

In blueprint.xml , I declare an optional dependency this way: <reference id=RepositoryListener interface=ru.focusmedia.odp.server.datastore.api.RepositoryListener availability=optional

  • 0

In blueprint.xml, I declare an optional dependency this way:

<reference id="RepositoryListener"
    interface="ru.focusmedia.odp.server.datastore.api.RepositoryListener"
    availability="optional" />

<bean id="Repository"
    class="ru.focusmedia.odp.server.datastore.jpa.repository.RepositoryImpl">
    <jpa:context property="entityManager" unitname="ODP_Server" />
    <tx:transaction method="*" value="Required" />
    <property name="repositoryListener" ref="RepositoryListener" />
</bean>

and in RepositoryImpl, I have

public void setRepositoryListener(RepositoryListener repositoryListener) {
    logger.info("Repository listener set");
    this.repositoryListener = repositoryListener;
}

This method is called by Blueprint even when there is no RepositoryListener service available, as expected. The problem is, how can I check later whether there is a service?

    if (repositoryListener != null) {
        repositoryListener.notifyDelete(node);
    } else {
        logger.warn("No repository listener set!");
    }

doesn’t work, since repositoryListener isn’t null, but a Blueprint proxy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:44:24+00:00Added an answer on June 4, 2026 at 4:44 pm

    There are three options.

    • Normally, if try and use the (missing) optional service, you’ll get a five minute delay while blueprint waits for a backing service to appear, followed by a ServiceUnavailableException. So one option is to set a very short blueprint timeout, and catch the ServiceUnavailableException.
    • An arguably cleaner option is to use a reference listener to monitor the lifecycle of the service. This has the disadvantage of needing extra code.
    • The simplest – and therefore laziest – option of all is to use an optional reference list instead of an optional reference. If no satisfying services are present, the list will be empty. Of course, you’ll have to think about what you want to happen if multiple satisfying services are present.

    To set a shorter timeout, just add an attribute to your optional service reference:

    <reference
        id="someReference"
        interface="org.some.service.ServiceInterface"
        availability="optional"
        timeout="100" />
    

    To use a reference listener, you’d add something like the following to your blueprint xml (there’s a more detailed example and discussion in chapter 6 of Enterprise OSGi in Action):

    <reference
            id="someReference"
            interface="org.some.service.ServiceInterface">
            <reference-listener
                ref="someBean"
                bind-method="bind"
                unbind-method="unbind" />
        </reference>
    

    The bind and unbind methods are called as your service appears and disappears (or as services get added and removed to your reference list, if you’re using a reference list).

    Using a reference list doesn’t really need a code example – just use a <reference-list element and ensure your setter method takes a List.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Gemini is the reference implementation for OSGi blueprint container, and Apache Aries is another
Anyone used the blueprint ( http://www.blueprintcss.org/ ) with Office Sharepoint server publishing sites? If
trying to use blueprint css framework, but can't understand why this is happening. I
I'm working on a webpage that involves using the Blueprint CSS Framework, as this
I am using this as a bit of a blueprint for setting up a
I use Blueprint CSS framework to style my site. I have this code: <div
I started using Blueprint CSS at about 8AM EDT this morning and I find
I had to change the blueprint of my webapplication to decrease loading time (http://stackoverflow.com/questions/5096127/best-way-to-scale-data-decrease-loading-time-make-my-webhost-happy).
I want to use the Blueprint CSS framework for this site I'm working on:
There's talk of this compressor script for blueprint css, where you can change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.