w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Bind order of OSGi declarative services
Make reference B use the "static" policy, which ensures it will be bound before the activate method is invoked. If reference E is declared as multiple/optional with the "dynamic" policy -- which is pretty much the only reasonable choice when you have a multiple reference -- then it will be bound/unbound whenever the services are published/unpublished. This can happen from any thread, and can even happen (multiple times!) during the invocation of the activate method.

Categories : Java

Accessing an osgi declarative service in a java project
FrameworkUtil.getBundle(Class) only returns non-null if the class you pass in was loaded by an OSGi bundle classloader. That means you actually need to be in an OSGi bundle. You need to be much clearer about what you're trying to do. "Accessing an OSGi DS in a Java project" is pretty much meaningless. Also since it seems you're just starting out with OSGi, why not start with something simple like working through a basic tutorial, rather than jumping in at the deep end? Finally notice that the following code snippet is nonsense: MyClass.class.getClass(). The literal MyClass.class already gives you the class you want... if you then call getClass on it you get the Class of java.lang.Class! This is almost certainly not what you wanted.

Categories : Java

OSGi/Equinox, Declarative Service and Lazy Load
Bundles in the RESOLVED state cannot provide services, and they will be ignored by Declarative Services. You should in general start all bundles during launch time, even if you want lazy loading behaviour. The key is to make the activation of the bundles cheap (or free!), and only pay for initialization of components when they are required. DS takes care of lazy activation by default already. There is nothing you need to enable or change for this to happen. Essentially DS publishes the service entry in the registry, but it does not actually instantiate your component (or even load its class) until some client tries to use the service. Furthermore, because DS does not load the class until required, OSGi does not even need to create a ClassLoader for the bundle, so long as your bundle does

Categories : Java

How do I get both Service Object and ServiceReference, when using declarative services
I'm not sure if you can bind two services in one bind-method. I would suggest to edit the component.xml to consume another service and create a third bind/unbind method for the Service Reference.

Categories : Java

Osgi synchronization services
Under specific constraints, yes, as the Equinox framework does not create proxies for services. However, that is a very brittle solution, as other parts of the system may or may not synchronize these calls... Did you know you can replace services in OSGi? Create a class that supports all the proper interfaces for your use case, but which is published as a service with a higher SERVICE_RANKING property than the existing service; this will cause this instance to be preferred when looking up services. Now, this class delegates all the method calls to the original service, which it obtains either using Declarative Services, a ServiceTracker or the BundleContext; in all cases using a Filter for SERVICE_RANKING. This allows you to intercept all method calls and f.e. log or synchronize them. H

Categories : Java

OSGi- Framework will only register certain Services
First, are the bundles that register these services started? I banged my head on the same problem only to find that in the default run configuration Eclipse/Equinox does not start automatically all bundles.

Categories : Java

Consume application/json in REST services using Jersey in Osgi
For the first question, I do not think you should have one function with two different signatures. I mean if you want to accept json or XML those are two different functions although they look the same from the java point of view. In your case I would create these three functions: @POST @Path("/adduser") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) public Message addUserXML(User user) { return addUserInternal(user); } @POST @Path("/adduser") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) public Message addUserJSon(User user) { return addUserInternal(user); } private Message addUserInternal(User user) { ... } As the second question: One of the worst thing that happened with Java 6 (in my opinion) is that they moved JAXB and o

Categories : Json

OSGi 'update' command; dynamic services wont restart
I guess you're not doing a refresh after update and IMath is exported by the math bundle? If you update a bundle, OSGi does not make the old class loader go away. That loader can only go away by garbage collection, i.e. no more class references exist. So when bundle 1 is updated, it creates a bundle 1', a new class loader. However, your bundle 2 is still bound to the bundle 1 class loader. To prevent class path exceptions, OSGi will not show any services to bundle 2 that are incompatible. Since bundle 1' now registers an IMath' service bundle 2 can no longer see this service because it looks for bundle 1's IMath, its class loader is still bound to bundle 1 for IMath. So this is the working situation: +----+ +----+ | b1 |-------<|-------| b2 |

Categories : Java

Running OSGI bundle from OSGI command prompt :Import-package missing constraint
After searching, I found the problem was with the manifest files. When exporting the jars in my settings I said use the manifest file already in the folder. I never looked at what the path was pointing to (assuming eclipse would set it correctly) however Eclipse hadn't changed its location so both jars were using the same Manifest file. Lesson learned. Always check the form before blindly pressing finish.

Categories : Java

Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=
The error message means that your bundle GoldeneyeModellingFramework imports the package com.host.domain.sharedpersonalize.storageservice but no bundle exports that package. Therefore the import cannot be resolved. You said that bundle GoldeneyeStorageService "includes" that package, but what does "includes" mean?? You need this package to be exported, i.e. listed in the Export-Package header. If the package is included in that bundle but not exported, then it is a private package that cannot be imported by any other bundle.

Categories : Java

WPF Events, declarative or handler?
Is either method considered best practice or are there other considerations? In general, I would prefer to keep the event handler declarations in the XAML, as this does make it a bit easier to follow (no need for the check for all children in the page load). Also, if you add a CheckBox to your Window/Control/etc that shouldn't be subscribed to, your Page_Load code would cause problems. That being said, many people would not consider either of these as "best practice", as code behind is often discouraged in WPF. Moving the check boxes to use bound properties within a ViewModel would often be considered the best practice.

Categories : Wpf

C++11 3.3.1p4 - Declarations in same declarative region?
They are not in the same single declarative region. The declarative region of the inner i is limited to within the innermost braces. In fact 3.3.1/2 has code remarkably similar to your own: int j = 24; int main() { int i = j, j; j = 42; } In that, the j used to set i is the 24 one but the scope of that outer j stops after the , and restarts at the }. Those two j variables are distinct despite the fact they're in the file declarative region for the same reasons as your example: the re are two declarative regions. Since there is not a single declarative region, scope takes control. C++11 3.3.1/1 states (my bold): Every name is introduced in some portion of program text called a declarative region, which is the largest part of the program in which that name is valid, that is,

Categories : C++

Declarative security for java ee application
Have you create authorized user of testgroup with file realm. If not you should follow the instructions of following link. http://docs.oracle.com/javaee/6/tutorial/doc/bncbx.html#gjjlk

Categories : Java

declarative transaction management in spring 3.1+
Advantages of annotaions way: Annotations are directly visible in the code. Advantages of xml way: You can reuse the same conf between multiple beans You can share some class between two applications and apply different transaction rules I prefer annotations where it is possible. It saves a lot of time when you read the code (you do not need open one more file and check it periodically). Other way for declarative transactions: use <aop:config> with <tx:advice>. See corresponding entry in official documentation. It is a variation of xml way that is more easy to do then ProxyFactoryBean (you do not need to wrap beans / declare transaction interceptor manually). Hope this helps.

Categories : Spring

Spring 3 Annotations: xml-less Declarative Transaction Management
You want to use the @Transactional annotation. Here's the documentation for it. Specifically, go to section 10.5.1. All you need to do is annotate the methods you want to have a transaction wrapped around with the annotation. With the annotation's values you can specify anything you want about the type of transaction.

Categories : Java

using flask-sqlalchemy without the subclassed declarative base
SQLAlchemy themselves actually recommend you use the Flask wrapper (db.Model) for Flask projects. That being said I have used the declarative_base model in several of my Flask projects where it made more sense. It does defeat the whole purpose of the SQLAlchemy class from flask-sqlalchemy. Here's some sample code: from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, sessionmaker import datetime #set up sqlalchemy engine = create_engine('postgresql://<username>:<password>@localhost/flask_database') Base = declarative_base() metadata = Base.metadata metadata.bind = engine Session = sessionmaker(bind=engine, autoflush=True) session = Session() class User(Base): __tablename__ = 'user' id = Column(In

Categories : Python

Rails, Devise, CanCan or Declarative authorization
I once made a huge app with allot of roles and each role had its sets of available actions, and i used devise and cancan and they work like a charm, they integrate quite well and both have great documentation. for the other question you can do something like this project model: has_one :user has_many :collaborators, :through => :team team model: belongs_to :user belongs_to :project

Categories : Ruby On Rails

Does Grails allow Declarative Exception Handling with Filters?
I guess you can handle declarative exception from Controllers but Filters. You can use response instead to send the error code class AuthorizationFilters { def filters = { auth(controller: 'error', invert: true) { before = { if(1){ //If auth fails response.sendError(403) //render(status: 403) //or //redirect(controller: 'error', action: 'status403') //or } return false } } } } Above logic will render the response from ErrorController's status403 action based on the UrlMapping that is provided in the question Make sure you are excluding error controller from filters.

Categories : Grails

Security issue with Migration when using declarative authorization gem
The documentation says to add the following, but it is wrong as Rails 3 vendor folder doesn't exist anymore in rails 3 and 4 : require "vendor/plugins/declarative_authorization/lib/maintenance" I asked in the google group and they give me the correct line : require 'declarative_authorization/maintenance' It works for me !

Categories : Ruby On Rails

Declarative approach to constrain data ranges in table
While waiting for next Oracle 12c version, which supports Temporal Validity, I still use next approach: create table item ( title varchar2(32) primary key ); create table price ( price_id number primary key, item varchar2(32) not null references item (title), price number(9,2), effective_from date not null, effective_to date not null, effective_prev_to date, constraint price_from_to_ck check ( effective_to > effective_from ), constraint price_to_prev_ck check ( effective_from = effective_prev_to + 1 ), constraint price_from_uq unique ( item, effective_to ), constraint price_dates_chain_fk foreign key ( item, effective_prev_to ) references price ( item, effective_to ) ); insert into item values ('LETTUCE'); in

Categories : SQL

Spring Declarative transaction management with hibernate using @Transactional
You want your iterations succeed or fail independently one from another. You want a failure in any of the 5 steps of the individual iteration to fail entire iteration and to roll back the corresponding transaction. It is clear that you want to have transaction boundary at the level of the service call that corresponds to a single iteration. Now, the rule of the thumb is to allocate a Hibernate session per transaction. So, a Hibernate session should be created at the beginning of each iteration and be disposed of at the end. That would prevent random junk, like entites that failed to be persisted to the database in the previous trnsactions, from showing up in the Hibernate session. Hope this helps.

Categories : Spring

How to define metaclass for a class that extends from sqlalchemy declarative base
to use the metaclass, it would have to derive from Declaratives DeclaredMeta in this case. But no metaclass is needed for this use case. Use mixins: from sqlalchemy.types import ( Integer, String, Boolean ) from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column Base = declarative_base() class SampleMixin(object): id = Column("Id", Integer, primary_key=True) name = Column("Name", String) description = Column("Description", String) is_active = Column("IsActive", Boolean) class Sample(SampleMixin, Base): __tablename__ = 'Sample' __table_args__ = {'useexisting': True} def __init__(self, id, name, description, is_active): self.id = id self.name = name self.description = description self

Categories : Python

Kendo declarative grid and making filterable.extra 'false'
You should use: data-filterable="{ extra: false}". So the declarative definition for the table would be: <table data-role="grid" data-sortable="true" data-filterable="{extra : false}" data-scrollable="false"> ... </table> See your example modified here http://jsbin.com/inikib/4/edit

Categories : Kendo Ui

Custom text filter on Kendo Grid that uses declarative initialization
Answering my own question... Working JSBin here What I needed was: $('.grid-filter').keyup(function() { var filterText = $(this).val(); $('.data-grid').data("kendoGrid").dataSource.filter = function () { return { field: "name", operator: "contains", value: filterText }; }; $('.data-grid').data("kendoGrid").dataSource.fetch(); }); I was missing $('.data-grid').data("kendoGrid").dataSource.filter and then $('.data-grid').data("kendoGrid").dataSource.fetch();

Categories : Kendo Ui

Declarative conditional validation of a field based on other one from parent model
My Suggestion Go to Tools => Library Package Manager => Package Manager Console and install Fluent Validation. Action Methods [HttpGet] public ActionResult Index() { var model = new Person { Name = "PKKG", IsActive = true, ContactDetails = new Contact { Email = "PKKG@stackoverflow.com" } }; return View(model); } [HttpPost] public ActionResult Index(Person p) { return View(p); } Fluent Validation Rules public class MyPersonModelValidator : AbstractValidator<Person> { public MyPersonModelValidator() { RuleFor(x => x.ContactDetails.Email) .EmailAddress() .WithMessage("Please enter valid email address") .NotNull().When(i => i.IsActive) .WithMessage("Please enter e

Categories : Dotnet

The Service on local computer started and then stopped ,Some services stop automatically if there are not in use by other services or programs
You need to specify the endpoint of the service (the URI at which the service can be reached by the client). You can do it in the code where you instantiate the ServiceHost (a very generic example): ServiceHost myHost = new ServiceHost(typeof(TechResponse), new Uri("http://www.somedomain.com/TechResponse"));

Categories : Dotnet

Azure Mobile Services app crashes with message- The app is not configured correctly to use Live Connect services
https://manage.dev.live.com/ is deprecated You need to associate your app to your Windows Store account then and then you can use Live services & push notifications. Right click on project name. Click on "Store" menu. Click "Associate App with the Store". It will prompt you for login. Do login with your store account. Click on the reserved name of your app (I think you must have reserved your app name otherwise go to Windows Store Dashboard and first reserve it.) Follow the other process which prompts. You project will get Store Key & new Package Identity. So it will allow you to leverage Live services & push notifications.

Categories : Azure

MapBinder not available in Guice 3.0
Add the multibindings module - it's part of the extensions: <dependency> <groupId>com.google.inject.extensions</groupId> <artifactId>guice-multibindings</artifactId> <version>3.0</version> </dependency>

Categories : Java

Guice Binding API by Example
Either the public no-argument constructor is used, or an @Inject-annotated constructor (that would be recommended). A new instance is returned every time, unless you specify a scope on ServiceImpl (either by a later bind(ServiceImpl.class).in(...) line or an @Singleton annotation on ServiceImpl. In this case, the same impl instance is used for every injection of Service That is a compile error, for good reason -- you can't specify a scope on a toInstance binding. bindConstant() should be used for things like configuration parameters that are primitive or String types. For more information, see this answer. @Provides methods are simply a shorter way of writing Provider<>s. If you don't have a need for them, don't use them. They should generally be used if creating an object is more

Categories : Java

My service is not reached when using guice + gwt
It looks like you are missing your application root in your GuiceServletConfig In your "MyGuiceServletConfig" try changing: serve("springGwtServices/*").with(ProjServiceImpl.class); To: serve("/showcase/springGwtServices/*").with(ProjServiceImpl.class); If that doesn't work then try adding the "/test" on the end instead of "/*" like so: serve("/showcase/springGwtServices/test").with(ProjServiceImpl.class); So that it matches you path in "ProjService" @RemoteServiceRelativePath("springGwtServices/test")

Categories : Gwt

NullPointerException with JPA, Eclipselink and Guice
My guess is that your persistence unit failed to start/initialize, or is not configured correctly. Enable logging on finest (in your persistence.xml) to see if any errors occurred on deployment. Also try using a debugger to see what is null.

Categories : Java

Guice missing annotations
Which JARs are you using? The main Guice 3.0 download page offers a ZIP file, which includes guice-3.0.jar but also feature packages like guice-multibindings-3.0.jar and guice-assistedinject-3.0.jar. One of those feature JARs is guice-throwingproviders-3.0.jar, which probably isn't on your classpath yet. Adding it should help.

Categories : Java

Injecting objects with Guice 3.0
Ideally SomeController shouldn't have to know the name of the database. This would come from a configuration file or from your application context and you'd inject your DAO like this: public class SomeController { private final SomeDAO someDAO; @Inject SomeController(SomeDAO someDAO) { this.someDAO = someDAO; } } And then to inject the database name you could do something like this: public class SomeDAO { @NotNull private DB db = null; @Inject public SomeDAO (@IndicatesDatabaseName String databaseName) throws Exception { ... } } In this case Guice will provide databaseName (see https://code.google.com/p/google-guice/wiki/BindingAnnotations). If you want to give the controller knowledge of the database name then you could consider just newing the DAO fro

Categories : Java

Giving a value to Provider in guice
I don't think you can do that. Guice bindings should always be specific; each binding key, which identifies what Guice has to inject at certain injection point, consists of a type and an a possible annotation: (Type, Optional<Annotation>) -> Implementation, and you cannot omit the type here, which is what you are really trying to achieve. However, Guice is able to bind wildcard types, i.e. it is possible to bind, say, List<?> to some provider (using TypeLiteral). So, I imagine, you should be able to create a class, say Cell<T>, which wraps an object of type T, and create a binding for Cell<?>. However, then you should be able to inject only Cell<?>, not a concrete type like Cell<String>. I don't know for sure, and maybe Guice allows such magic, but i

Categories : Java

How to wrap an instance using Guice
You have a couple options, depending on how much injection flexibility you need. One way is to create your instance yourself, enhance it as you see fit, and then inject the fields and methods using an injected MembersInjector as needed. This precludes you from using constructor injection, or at least requires you to fulfill constructor injection yourself, but does the trick cleanly: public class YourModule extends AbstractModule { @Override public void configure() { } @Provides YourClass provideEnhancedYourClass( MembersInjector<YourClass> yourClassInjector, YourDependency dependency) { YourClass yourClass = YourClassEnhancer.enhance(new YourClass(dependency)); yourClassInjector.injectMembers(yourClass); return yourClass; } } Another way is a little

Categories : Misc

Combinding Guice and JAXB
tell JAXB to use Guice's Injector as object factory I don't think it is possible. The closest thing you can get is on-demand injection, that is, injection in already existing object; this will work, obviously, only for injectable fields and methods, not constructors. By the way, JAXB classes usually represent data, don't they? Then they really should not have any dependencies because this is likely a violation of single responsibility principle - data classes should only contain and transfer data, nothing more. Move your logic code out of JAXB classes to separate classes which operate on JAXB classes. Then you can use Guice to instantiate these "service" classes.

Categories : Java

Injecting Class using guice
Yes, you can do it using Guice's built-in injection of TypeLiterals. public class Main { public static void main(String[] args) { Injector injector = Guice.createInjector(); Test<Integer> testInt = injector.getInstance(Key.get(new TypeLiteral<Test<Integer>>() {})); testInt.action(); Test<String> testString = injector.getInstance(Key.get(new TypeLiteral<Test<String>>() {})); testString.action(); } public static class Test<T> { private final Class<? super T> clazz; @Inject public Test(TypeLiteral<T> literal) { this.clazz = literal.getRawType(); } public void action() { System.out.println(clazz); } } } I'm

Categories : Java

Can I get the instance in a method using Guice?
Unfortunatelly you cannot place annotations on local variables. This limitation comes from Java and not from Guice. According to this answer there is hope that we get this feature in future Java versions. But please note that even if this would work it wouldn't be a good practice. The idea of dependency injection is the ability to change dependencies from outside of a class. A local variable does not fit into this because it cannot be changed from outside the class.

Categories : Java

Guice does not load Bindings
This is the problem, I believe: @Named('Mars') Add a = injector.getInstance(Add) You're just asking for an instance of Add - the fact that the variable you're assigning the result to has the @Named annotation is irrelevant to Guice. I believe you'll need to use Injector.getInstance(Key) with a key for the right class with the right name binding, e.g. Add add = injector.getInstance(Key.get(Add, Names.named('Mars')))

Categories : Java

GWT gin/guice injection order
There was a bug in GIN up to 2.0, it's been fixed in 2.1. https://code.google.com/p/google-gin/issues/detail?id=183

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.